[openbox] Swap Windows Between Screens in Xinerama Mode
Adam Kessel
adam at rosi-kessel.org
Wed Jun 9 11:19:19 EDT 2004
On Wed, 2004-06-09 at 09:48, John Russell wrote:
> > ID=`xdpyinfo | grep focus | cut -d ' ' -f 4 - | cut -d ',' -f 1`
> > xdpyinfo | grep focus | grep Parent &> /dev/null && ID=$((ID-1))
> That is quite an excellent script. Thanks.
Yup. Here's my script to swap the active window to the other display.
I had to do some hack to convert the ID back to hexadecimal (using
iprint) in order for it to be greppable from the wmctrl list. It's also
necessary to raise/activate the swapped window as it seems to lose focus
otherwise. Again, a little awkward, but it works:
#!/bin/bash
WIDTH=1400
ID=`xdpyinfo | grep focus | cut -d ' ' -f 4 - | cut -d ',' -f 1`
xdpyinfo | grep focus | grep Parent &> /dev/null && ID=$((ID-1))
ID=`i $ID | cut -d ' ' -f 2`
GREPID=${ID/0x/}
WIN=`wmctrl -G -l | grep -i $GREPID | awk '{print $1 "." $3}'`
ID=${WIN%%.*}
POSITION=${WIN#*.}
if [ $POSITION -gt $WIDTH ] || [ $POSITION -eq $WIDTH ]
then
NEWPOSITION=$(($POSITION-$WIDTH))
else
NEWPOSITION=$(($POSITION+$WIDTH))
fi
PROPERTIES=`xprop -id $ID`
echo $PROPERTIES | grep -q "_NET_WM_STATE(ATOM).*MAXIMIZED_VERT"
VERT=$?
echo $PROPERTIES | grep -q "_NET_WM_STATE(ATOM).*MAXIMIZED_HORZ"
HORZ=$?
if [ $VERT == 0 ]; then wmctrl -i -r $ID -b remove,maximized_vert; fi
if [ $HORZ == 0 ]; then wmctrl -i -r $ID -b remove,maximized_horz; fi
wmctrl -i -r $ID -e 0,$NEWPOSITION,-1,-1,-1
if [ $VERT == 0 ]; then wmctrl -i -r $ID -b add,maximized_vert; fi
if [ $HORZ == 0 ]; then wmctrl -i -r $ID -b add,maximized_horz; fi
wmctrl -i -a $ID
--
Adam Kessel
http://adam.rosi-kessel.org
More information about the openbox
mailing list