[openbox] Swap Windows Between Screens in Xinerama Mode
Adam Kessel
adam at rosi-kessel.org
Tue Jun 8 15:39:55 EDT 2004
On Tue, 2004-06-08 at 15:12, John Russell wrote:
> > 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.
Okay, here's the resulting script. It's still fairly clunky, but at
least doesn't call wmctrl as many times. It's too bad there's no way to
move the window without unmaximizing and remaximizing it. Any
additional suggestions are appreciated.
One additional feature I added is it now only swaps between screens for
the current desktop (this assumes you have < 10 desktops):
#!/bin/bash
IGNORE="gkrellm"
WIDTH=1400
CURRENT_DESKTOP=`wmctrl -d | grep "*" | sed "s/^\(.\).*/\1/"`
for WIN in `wmctrl -G -l | grep -iv $IGNORE | grep "^.\{10\}
$CURRENT_DESKTOP" | 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
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
done
--
Adam Kessel
http://adam.rosi-kessel.org
More information about the openbox
mailing list