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).
The problem is in the last if-statement if [[ $currentWindowPosition == "above" ]]. When I call the script from terminal and my window in the the monitor above I get:
currentWindowPosition=above!
The window will stay on this monitor
but when I call it from a keyboard shortcut (and redirect the output to a file) I get:
currentWindowPosition=above!
The current monitor is on the bottom
How come? I also tried different versions of that test but without success. Thank you in advance.
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
Aucun commentaire:
Enregistrer un commentaire