#!/bin/bash

## this is a simple script to move windows between my 2 monitors without having to reach for the damn mouse
## this script requires xdotool and wmctrl installed
## update POS with your own resolution/geometry, the below is for 1920x1080

## I have a dual monitor setup and to use this script with Gnome2 I added two shortcuts in the preferences:
## "windows key + left arrow" calls this script with "1" as parameter and will move the focused window to the left monitor
## "windows key + right arrow" calls this script with "2" as parameter and will move the focused window to the right monitor

if [ $1 -eq 2 ]
then
    POS="1920 0"
else
    POS="0 0"
fi

## for some reason some maximised apps would not move, so we're unmaximising them, once on the right monitor you can fix this with alt+F10
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
xdotool windowmove `/usr/bin/xdotool getwindowfocus` $POS

exit 0
