title: Bash script - determine if script launched in terminal console or gui
body: <p>How to find out if script launched using terminal console or without, in gui by .desktop file for example?</p>
  
  <p>I have look over <code>env</code> output and some variables looks promising to check, like test $TERM var. But I want known for sure and a compatible/portable way to do it.</p>
  
  <p>This is needed for script what will have two behaviors for user input, fallback to terminal read or gui input.</p>