Define a custom shortcut for Compiz Window Manager

Ralf Mardorf silver.bullet at zoho.com
Sat Apr 23 08:38:55 UTC 2016


On Sat, 23 Apr 2016 11:36:47 +1000, Karl Auer wrote:
>eval $(xdotool getwindowgeometry --shell $(xdotool getactivewindow))
>echo "$WINDOW: ($SCREEN),$X,$Y,$WIDTH,$HEIGHT"
>NY=$Y
>NY=$(calc $Y-28)
>wmctrl -i -r $WINDOW -e "0,$X,$NY,$WIDTH,$HEIGHT"
>sleep 1
>eval $(xdotool getwindowgeometry --shell $WINDOW)
>echo "$WINDOW: ($SCREEN),$X,$Y,$WIDTH,$HEIGHT"

>If I remove the sleep, then *sometimes* the values returned are the
>same, even though the window has moved!

Did you try "&&" before you used "sleep"? I don't need it. Perhaps my
graphics or something else is slower than yours.

Yesterday I didn't check if there's a fixed relation between the values.
Thank you Karl, for doing so.
However, I don't have a rational explanation for the values needed to
fix the position on my install.

I'm using a config file for the values to fix the x/y offsets.


$ cat ~/.rocketmouse/win75/config 
X_FIX=4
Y_FIX=50


$ cat /usr/local/bin/win75 
#!/bin/bash
eval $(xdotool getwindowgeometry --shell $(xdotool getactivewindow))
X_FIX=$(grep X_FIX ~/.rocketmouse/win75/config | cut -d"=" -f2)
Y_FIX=$(grep Y_FIX ~/.rocketmouse/win75/config | cut -d"=" -f2)
((XX=X-X_FIX))
((YY=Y-Y_FIX))
WIDTH=$(calc "int($WIDTH*0.75)")
case $1 in
  "") HEIGHT=$(calc "int($HEIGHT*0.75)");;
esac
echo "x:$X-$X_FIX=$XX/y:$Y-$Y_FIX=$YY"
wmctrl -i -r $WINDOW -b remove,maximized_vert,maximized_horz
wmctrl -i -r $WINDOW -e "0,$XX,$YY,$WIDTH,$HEIGHT"
eval $(xdotool getwindowgeometry --shell $(xdotool getactivewindow))
echo "x:$X-$X_FIX=$XX/y:$Y-$Y_FIX=$YY"
exit


$ win75
x:205-4=201/y:266-50=216
x:205-4=201/y:266-50=216
$ win75
x:205-4=201/y:266-50=216
x:205-4=201/y:266-50=216
$ win75 -
x:205-4=201/y:266-50=216
x:205-4=201/y:266-50=216
$ win75 -
x:205-4=201/y:266-50=216
x:205-4=201/y:266-50=216


$ win75
x:0-4=-4/y:80-50=30
x:0-4=-4/y:80-50=30
$ win75
x:0-4=-4/y:80-50=30
x:0-4=-4/y:80-50=30
$ win75 -
x:0-4=-4/y:80-50=30
x:0-4=-4/y:80-50=30
$ win75 -
x:0-4=-4/y:80-50=30
x:0-4=-4/y:80-50=30

Based on your script and my script, the OP should be able to get what is
wanted.

Getting the dependencies for both scripts:

$ sudo apt-get update && sudo apt-get install apcalc wmctrl xdotool

Regards,
Ralf




More information about the ubuntu-users mailing list