title: String comparison in a Bash script called from terminal or keyboard shortcut gives different output
body: <p>I have two monitors and I am calling a bash script to move the current window to the monitor above. Below there is a sample of my code (I changed the variable names to be more descriptive). </p>
  
  <p>The problem is in the last if-statement <code>if [[ $currentWindowPosition == "above" ]]</code>. When I call the script from terminal and my window in the the monitor above I get: </p>
  
  <pre><code>currentWindowPosition=above!
  The window will stay on this monitor
  </code></pre>
  
  <p>but when I call it from a keyboard shortcut (and redirect the output to a file) I get: </p>
  
  <pre><code>currentWindowPosition=above!
  The current monitor is on the bottom
  </code></pre>
  
  <p>How come? I also tried different versions of that test but without success. Thank you in advance.</p>
  
  <pre><code>yOfCurrentWindow=$(xwininfo -id $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}') | grep "Absolute upper-left Y:" | cut -d: -f2)
  yResolutionOfmonitor1=$(xrandr | awk '/ connected/ { print $3 }' | sed -n '1 p' | awk 'BEGIN{FS="x"} { print $2}' | awk 'BEGIN{FS="+"} {print $1}')
  
  if [ $yOfCurrentWindow -lt $yResolutionOfmonitor1 ] 
  then currentWindowPosition="above"
  else currentWindowPosition="below"
  fi
  
  echo "currentWindowPosition=$currentWindowPosition!"
  
  if [[ $currentWindowPosition == "above" ]] 
  then echo "The window will stay on this monitor"
  else echo "The current monitor is on the bottom"
  fi
  </code></pre>