Compiz, Aero Snap and one addition

I moved from Windows to Ubuntu many months ago, and I couldn't be happier. But there was a particular thing that I liked about Windows 7: Aero Snap - you know, that feature in which by pressing WIN + arrow you get to position your window, maximize or minimize it.

Some time ago I found a page (sorry dude, I don't remember which one but here you have a nice start) which showed how to mimic some of those features in Compiz. Tried it, liked it, tweaked it and I've been using it for months now. FYI, you need the compizconfig-settings-manager and wmctrl packages:

sudo apt-get install compizconfig-settings-manager wmctrl

But now I've extended this a little bit more. Some times I want to position a window in the top right corner of my screen, or any other corner, so I came up with these commands (you'll need to check the previous link to know where to place them):

Move window to the bottom right corner:

wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert && SCREEN_WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x' ` && SCREEN_HEIGHT=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 2 -d 'x'  | cut -f 1 -d ' '` && WINDOW_WIDTH=`xwininfo -id $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}') | grep Width | cut -f 2 -d ':'` && WINDOW_HEIGHT=`xwininfo -id $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}') | grep Height | cut -f 2 -d ':'` && POSITIONX=$(($SCREEN_WIDTH - $WINDOW_WIDTH)) && POSITIONY=$(($SCREEN_HEIGHT - $WINDOW_HEIGHT - 30)) && wmctrl -r :ACTIVE: -e 0,$POSITIONX,$POSITIONY,-1,-1

You can change the very last bit of this "line" to achieve different positions. For example, replce

wmctrl -r :ACTIVE: -e 0,$POSITIONX,$POSITIONY,-1,-1

with

wmctrl -r :ACTIVE: -e 0,$POSITIONX,0,-1,-1

to move the window to the top right corner. This piece of code is easy to add to the Commands plugin of Compiz, assign a shortcut to each of the four possible corners and position the current window there perfectly and quickly.

In case you're wondering, I'm using WIN + <;|'|.|?>, that is, the 4 keys at the left of the right shift, easy enough to remember which one corresponds to each corner.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.