2

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?

  • As you execute the command in terminal, here the active window is terminal. So, it takes effect only on terminal. – Wolverine Dec 31 '14 at 12:35
  • with the sleep 1, I can change to another window, like a Chrome browser, and then the command takes effect there. I can also do Alt+F2 and execute the bash file, and it works. What does not work is the keybinding. – 719016 Jan 3 '15 at 8:51
  • Yep. You are right!!! The time interval is the key factor of making effect of the command on other windows. But you have to make it with shortcut key as you said earlier that you wanted to do it by shortcut key. I have tried of using native keyboard shortcut options on System Settings. It doesn't work. That's why I preferred over Keybinding application. – Wolverine Jan 3 '15 at 11:17
  • I tried with control+alt+b with xbindkeys but it does not work for me. – 719016 Jan 3 '15 at 11:54
  • What is your script file name? – Wolverine Jan 3 '15 at 11:58
0
+50

Here the steps:

  1. Create a script file that starts the line #!/bin/bash followed by your command given in the question.
  2. sudo apt-get install xbindkeys
  3. Type:

    printf '"bash $HOME/bin/left.sh"\n Control+Alt+A\n' > ~/.xbindkeysrc 
    printf '"bash $HOME/bin/right.sh"\n Control+Alt+F\n' >> ~/.xbindkeysrc
    
    xbindkeys
    

Now, check out if it does work.

I hope it will work.

| improve this answer | |
  • No luck... I tried different shortcut combinations, but none of them works. – 719016 Dec 31 '14 at 13:17
  • I tried it. It works well for me. But I didn't try with Super + Left. I tried with other shortcut keys. It works well. First, check out with other shortcut keys like the one I mentioned in the answer. – Wolverine Dec 31 '14 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.