sudo yum install xdotool
Create a file called move-window-to-display.sh. I prefer to place my scripts in ~/bin but any directory will work.
#!/bin/bash
if [ $1 -eq 2 ]; then
POS="1680 0"
else
POS="0 0"
fi
/usr/bin/xdotool windowmove `/usr/bin/xdotool getwindowfocus` $POS
exit 0
Next we need to make this new script executable:
sudo chmod +x ~/bin/move-window-to-display.sh
The script above is written assuming your monitors are 1680 pixels wide. If your monitor is wider or narrower change the value of $POS from "1680 0" to "1024 0" or "1440 0", etc. The settings I've placed here also put the window in the top left corner of the monitor upon being moved. If you wish to place it elsewhere you can treat these numbers as X and Y pixel coordinates and put whatever value in them you would like. The first definition of $POS is for the right monitor and the $POS in the "else" portion is for the left monitor.Finally we need to assign it to a keyboard shortcut. I chose Alt+Shift+{LEFT,RIGHT} but you can choose whatever you like as long as it doesn't conflict with another shortcut (I found that combinations with the super key did not work for some reason as well). You can set these by going to the Gnome "Keyboard" tool. Click "Shortcuts" at the top and go to "Custom Shortcuts" on the bottom of the left hand list. From there, click the [+] button and give the shortcut a name and in the "Command" field give the full path of the above script and at the end append a "1" or "2" depending on which monitor you would like to move to.
No comments:
Post a Comment