2015. január 10.

Aero snap for Ubuntu 14.04 Flashback with Metacity

In this AskUbuntu post, a solution is described to have the Aero snap to left and right in Metacity Ubuntu. This AskUbuntu post, from the same user, is aiming to develop the solution further. I'll just cover the info from the first post here:

EDIT: I changed the code a little bit to fit my screen better.

You'll need to install two packages for this thing to work:
sudo apt-get install wmctrl xbindkeys

Than you'll need to create two scripts: one for snap left and one for snap right:
Create the files in terminal and give them right to execute by:
sudo touch /bin/snapleft.sh
sudo chmod ugoa+rx /bin/snapleft.sh
sudo touch /bin/snapright.sh
sudo chmod ugoa+rx /bin/snapright.sh 

Open the snapleft.sh by
sudo gedit /bin/snapleft.sh

Copy this text into it:
#!/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)-2)}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`

than save and close it.
Open the snapright.sh by
sudo gedit /bin/snapright.sh

Copy this text into it:
#!/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))}'`,0,`xwininfo -root | grep Width | awk '{ print (($2/2))}'`,`xwininfo -root | grep Height | awk '{ print $2 }'`
than save and close it.

Now set the keyboard shortcuts with xbinkeys (to the left-side "super"/windows key and the left and right arrow keys) by
printf '"bash /bin/snapleft.sh"\n Mod4 + Super_L + Left\n' > ~/.xbindkeysrc 
printf '"bash /bin/snapright.sh"\n Mod4 + Super_L + Right\n' >> ~/.xbindkeysrc

You can check the name of a key (if something is amiss) with
xbindkeys -k


NEW STUFF:

To have a snap up and snap down function use the above guide with the following changes:

script name: snapup.sh
script content:
#!/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 }'`,`xwininfo -root | grep Height | awk '{ print (($2/2)-40)}'`
binding key: Mod4 + Super_L + Up

script name: snapdown.sh
script content:
#!/bin/bash
sleep 0.1 && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,0,`xwininfo -root | grep Height | awk '{ print (($2/2))}'`,`xwininfo -root | grep Width | awk '{ print $2 }'`,`xwininfo -root | grep Height | awk '{ print (($2/2)-40)}'`
binding key: Mod4 + Super_L + Down

Nincsenek megjegyzések: