[openbox] Swap Windows Between Screens in Xinerama Mode
Adam Kessel
adam at rosi-kessel.org
Tue Jun 8 14:43:54 EDT 2004
On Tue, 2004-06-08 at 12:49, John Russell wrote:
> I use this when I undock my laptop. It is kind of a sledge hammer, but
> it works. THe grep statements are to have it not move things that I want
> to be left alone. Have fun
That was a good start. I needed to modify it substantially to actually
swap windows. Apparently, wmctrl won't move a window from one side to
the other if it's maximized, and I don't see any way to tell whether
it's maximized other than by looking at the window's dimensions. So I
get the following script, which is really a terrible hack. It is also
rather slow. Any ideas for improvement are appreciated:
------------
#!/bin/bash
IGNORE="gkrellm"
WIDTH=1400
HEIGHT=1050
for WIN in `wmctrl -G -l | grep -iv $IGNORE | awk '{print $1 "." $3}'`
do
ID=${WIN%%.*}
POSITION=${WIN#*.}
if [ $POSITION -gt $WIDTH ] || [ $POSITION -eq $WIDTH ]
then
NEWPOSITION=$(($POSITION-$WIDTH))
else
NEWPOSITION=$(($POSITION+$WIDTH))
fi
X=`wmctrl -l -G | grep $ID | awk {'print $5'} | sed "s/[^0-9]//g"`
Y=`wmctrl -l -G | grep $ID | awk {'print $6'} | sed "s/[^0-9]//g"`
if [ $Y -gt $(($HEIGHT-100)) ]
then
wmctrl -i -r "$ID" -b remove,maximized_vert
fi
if [ $X -gt $(($WIDTH-100)) ]
then
wmctrl -i -r "$ID" -b remove,maximized_horz
fi
wmctrl -i -r "$ID" -e 0,$NEWPOSITION,-1,-1,-1
if [ $Y -gt $(($HEIGHT-100)) ]
then
wmctrl -i -r "$ID" -b add,maximized_vert
fi
if [ $X -gt $(($WIDTH-100)) ]
then
wmctrl -i -r "$ID" -b add,maximized_horz
fi
done
--
Adam Kessel
http://adam.rosi-kessel.org
More information about the openbox
mailing list