[openbox] Swap Windows Between Screens in Xinerama Mode

John Russell drjimmy42 at yahoo.com
Tue Jun 8 15:12:20 EDT 2004


Adam Kessel wrote:
> 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:

Try greping through the output of xprop.  It should show you the 
maximized state of your window.  That would also work even on screens of 
different sizes/resolutions.

e.g.
_NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_VERT

You can run xprop on a window id which you can grep out of the wmctrl -l 
output.  I love grep.

John

> 
> ------------
> 
> #!/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
> 



More information about the openbox mailing list