After a bit of digging here:
http://ubuntuforums.org/showthread.php?t=760651
and here:
http://www.ruby-forum.com/topic/165740#728314
it looks like there's a solution. Try this in your script to get the current active window's X pos (or Y pos, just change the "Absolute upper-left X" to "Y"):
Code:
x=$(xwininfo -id `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| cut -d ' ' -f 5` | grep "Absolute upper-left X" | cut -d ' ' -f 7)
I've also grabbed the display resolutions via xorg.conf, so here's a new script that implements these changes:
Code:
#!/bin/bash
offx=$( grep metamodes /etc/X11/xorg.conf | cut -d '+' -f 4 | sed 's/[^0-9]*//g' )
offy=$( grep metamodes /etc/X11/xorg.conf | cut -d '+' -f 5 | sed 's/[^0-9]*//g' )
curx=$(xwininfo -id `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| cut -d ' ' -f 5` | grep "Absolute upper-left X" | cut -d ' ' -f 7)
cury=$(xwininfo -id `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| cut -d ' ' -f 5` | grep "Absolute upper-left Y" | cut -d ' ' -f 7)
if [ $curx -ge $offx ]
then
newx=$((curx-offx))
newy=$((cury-offy))
else
newx=$((curx+offx))
newy=$((cury+offy))
fi
/usr/bin/xdotool windowmove `/usr/bin/xdotool getwindowfocus` $newx $newy
exit 0
There's probably a better sed command to find the display resolutions (I'm definitely no sed guru - in fact, it's a tool I still find incredibly hard to use after years of wrangling with it) and when I use the script to move a window, repeated moves means the window slowly gets lower on each screen, so there's pixels being added to the newy value for some reason, but I can't work out why.
Anyway, let me know if this works for you.
Bookmarks