I am trying to get the Aero Snap effect working on an Ubuntu 14.10 using Gnome Classic Metacity.
I found a command that works if I execute in on a terminal window:
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,`xwininfo -root | grep Width | awk '{ print (($2/2))}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`
And I can run it with a sleep 1 to have time to switch to the window I want to resize:
sleep 1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,`xwininfo -root | grep Width | awk '{ print (($2/2))}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`
It works well.
I can also run it as a bash script in my $HOME/bin/left.sh and $HOME/bin/right.sh, or shorter, Alt+F2 then $HOME/bin/aaa for left and $HOME/bin/fff for right. It also works on the active window behind the Alt+F2 menu.
Now I want to hook up this command to a keyboard shortcut. I tried:
System Settings -> Keyboard -> Shortcuts -> Custom Shortcuts -> "Aero Left" - Super+Left
which I link to a /bin/bash /home/myusername/bin/aero_left.sh with the command line above. But it has no effect. Again, running the bash command in a terminal window does work, but the keyboard shortcut does not.
In fact, not much happens for any of the Custom Shortcuts I try to set up:
/usr/bin/mplayer /usr/share/aisleriot/sounds/splat.ogg
or
/bin/bash -c "/usr/bin/mplayer /usr/share/aisleriot/sounds/splat.ogg"
and try to hook it to any kind of keyboard combination, it doesn't work...
UPDATE: I tried xbindkeys and none of my examples are working. Still mesmerized as to why the Custom Shortcuts do not do much. Looking forward to a solution.
[hpenvy15 ~] $ mkdir ~/bin ; ls -l -d1 ~/bin | wc -l
1
[hpenvy15 ~] $ cat > ~/bin/left.sh
#!/bin/bash
sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,0,`xwininfo -root | grep Width | awk '{ print (($2/2))}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`
^C
[hpenvy15 ~] $ cat > ~/bin/right.sh
#!/bin/bash
sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,`xwininfo -root | grep Width | awk '{ print (($2/2)+5) ",0," (($2/2)) }'`,`xwininfo -root | grep Height | awk '{ print $2 }'`
^C
[hpenvy15 ~] $ sudo apt-get install xbindkeys
Reading package lists... Done
Building dependency tree
Reading state information... Done
xbindkeys is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
printf '"bash $HOME/bin/left.sh"\n Mod4+Super_L+Left\n' > ~/.xbindkeysrc
printf '"bash $HOME/bin/right.sh"\n Mod4+Super_L+Right\n' >> ~/.xbindkeysrc
xbindkeys
If I then type control+alt+b I can hear a drum sound, but nothing happens.
Any ideas?
control+alt+bwith xbindkeys but it does not work for me. – 719016 Jan 03 '15 at 11:54$HOME/bin/aaafor what I would like to beSuper+leftand$HOME/bin/ffffor what I would like to beSuper+right. – 719016 Jan 03 '15 at 12:35printf '"bash $HOME/bin/left.sh"\n Control+Alt+B' > ~/.xbindkeysrc. Then, typexbindkeysto start xbindkeys in background. If you ever changed existing shortcut key in thexbindkeysrcfile, you will have to kill the xbindkeys, application running in background, by typingkillall xbindkeysand restart it by typingxbindkeys. – Wolverine Jan 03 '15 at 13:17