Wednesday, May 16, 2012

Linux tip

I have two monitors and since Ubuntu version 12.04, moving windows from one monitor to the other became 'harder' (well, it's better than before, where moving from one monitor to the other was too easy).
So, I've wrote some script for moving window or mouse cursor from one side to the other:

my script look as following:


file /home/michaelz/util/move-window-to-display.sh
#!/bin/bash
# Copied and inspired from  http://ubuntuforums.org/showthread.php?t=1414155
if [ $1 -eq 2 ]
then
    POS="1700 0"
else
    POS="0 0"
fi
/usr/bin/xdotool windowmove `/usr/bin/xdotool getwindowfocus` $POS
exit 0

I just added to add a Custom Shortcut to my keyboard ( Keyboard / Add Custom) to this script like:


for moving to the left monitor
/home/michaelz/util/move-window-to-display.sh 1 
for moving to the right  monitor (or vice-versa)
/home/michaelz/util/move-window-to-display.sh 2 


For moving my cursor:
To the left:
xdotool mousemove 0 20
To the right:
xdotool mousemove 2000 20


No comments: