[conspire] Cool trick- reposition a window (e.g. Firefox) programmatically

Tony Godshall togo at of.net
Thu Oct 7 17:35:08 PDT 2010


Assumptions:

You've installed wmctrl from you favorite distro's repo (e.g. #
apt-get update && apt-get install wmctrl )

You've already got Firefox running

1. calculate the dimensions, in this case I want firefox to be full
width, bottom half

$ DISPGEOM=$(xwininfo -root|awk '/-geometry/{print $2}')
$ echo $DISPGEOM
1280x800+0+0

$ DISPW=$(echo "$DISPGEOM"|cut -dx -f1); echo $DISPW
1280
$ DISPH=$(echo "$DISPGEOM"|cut -dx -f2|cut -d+ -f1); echo $DISPH
800

$ let H=DISPH/2
$ let W=DISPW
$ let x=0
$ let y=DISPH-H

2. Tell the window manager to use that size for the window with
Firefox in its title

$ wmctrl -a 'Firefox' -e 0,$x,$y,$W,$H

Read the manpage for caveats.  Tested to work fine with compiz and
metacity (the defaults for Ubuntu with Appearance ,Effects, None and
Extra.

Best Regards.




More information about the conspire mailing list