i use compiz's grid alongside easystroke (a mouse gestures application)
it works better than the original aero snap to be honest, as i don't have to actually move the window, i just paint a line towards where i want it to go.
i also liked it better than the idea suggested on the posts before mine (i have tried that one as well)
Im hot on trail for a possible solution however it may take me some time. I know we can detect x11 input events using C++ however my code knowledge isnt quite that advanced. Basicly all we need to do is run the following pseudocode:
I am aiming at just creating a single script that will house all the commands so we are not looking at the word salad that we posted before. Something like windowcheck.sh --maximizeCode:if X11InputEvent.clicked = true { execute resize command; } else { // do nothing }
I will work more on it tommorow since its my day off
well, I think i may have found the solution but I dont know enough about shell scripting to figure out the new issue I am having. If you know anything about shell scripting please take a look at the following code and help me debug it.
the xinput line needs to be set to the id of your mouse (just run "xinput list" to find it out)Code:#!/bin/sh if [ xinput --query-state 11 | grep down ] then wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz else exit 1 fi
Last edited by gotsanity; April 29th, 2010 at 05:48 AM. Reason: edited for typos
Fixed! Snap on grabbed windows only!
First open a terminal and type:
make a note of your mouse's ID# and execute a few more commands:Code:xinput list
Create the following three files (DON'T FORGET: MOUSE="11" needs to be changed to your mouse's id# in all three files):Code:cd mkdir .scripts cd .scripts
compizsnap-left.sh
compizsnap-right.shCode:#!/bin/sh # # CompizSnap is a collaborative project from ubuntuforums.org and is free software. # This script adds window snapping functionality to compiz using the commands plugin. # # Directions: run "xinput list" to find your mouse's ID# and then edit the MOUSE variable below: # MOUSE="11" # ----- Don't edit below this line unless you know what you are doing. WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2-10)) echo $WIDTH TEMPWIDTH=$(($WIDTH-10)) echo $TEMPWIDTH if /usr/bin/X11/xinput --query-state $MOUSE | grep down then while (/usr/bin/X11/xinput --query-state $MOUSE | grep down) do echo 'button pressed' done if [ "$(/usr/bin/X11/xinput --query-state $MOUSE | grep "valuator\[0\]=." | sed s/"valuator\[0\]="//)" -le 10 ] then wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-10 else echo "exiting without matching" exit 1 fi else echo "exiting because button isnt " exit 1 fi
compizsnap-max.shCode:#!/bin/sh # # CompizSnap is a collaborative project from ubuntuforums.org and is free software. # This script adds window snapping functionality to compiz using the commands plugin. # # Directions: run "xinput list" to find your mouse's ID# and then edit the MOUSE variable below: # MOUSE="11" # ----- Don't edit below this line unless you know what you are doing. WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) echo $WIDTH TEMPWIDTH=$(($WIDTH-10)) echo $TEMPWIDTH if /usr/bin/X11/xinput --query-state $MOUSE | grep down then while (/usr/bin/X11/xinput --query-state $MOUSE | grep down) do echo 'button pressed' done if [ "$(/usr/bin/X11/xinput --query-state $MOUSE | grep "valuator\[0\]=." | sed s/"valuator\[0\]="//)" -ge $TEMPWIDTH ] then wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$HALF,-1 else echo "exiting without matching" exit 1 fi else echo "exiting because button isnt " exit 1 fi
Now, Fire up Settings > Preferences > CompizConfig Settings Manager and then select the Commands plugin.Code:#!/bin/sh # # CompizSnap is a collaborative project from ubuntuforums.org and is free software. # This script adds window snapping functionality to compiz using the commands plugin. # # Directions: run "xinput list" to find your mouse's ID# and then edit the MOUSE variable below: # MOUSE="11" # ----- Don't edit below this line unless you know what you are doing. if /usr/bin/X11/xinput --query-state $MOUSE | grep down then while (/usr/bin/X11/xinput --query-state $MOUSE | grep down) do echo 'button pressed' done if [ "$(/usr/bin/X11/xinput --query-state $MOUSE | grep "valuator\[1\]=." | sed s/"valuator\[1\]="//)" -le 10 ] then wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz else echo "exiting without matching" exit 1 fi else echo "exiting because button isnt " exit 1 fi
Set Command 0:
Set Command 1:Code:sh ~/.scripts/compizsnap-left.sh
Set Command 2:Code:sh ~/.scripts/compizsnap-right.sh
And last of all select the Edge Bindings tab and set the appropriate commands to the appropriate edges.Code:sh ~/.scripts/compizsnap-max.sh
Thats all there is to it!
Last edited by gotsanity; May 1st, 2010 at 06:12 AM. Reason: Edited to reflect changes in dynamics and for click release.
Brilliant,well done gotsanity!
Just tried it and works.
Just a bit of a noob question....
How come it works without making the scripts executable?
Last edited by stinkeye; April 29th, 2010 at 10:58 AM.
gotsanity, brilliant, it works! Not 100% reliably (especially not if you are testing dragging left, right and top without releasing) but it works pretty good if you use it 'normally'. Thanks a lot!
Thanks gotsanity, that actually works quite well.
The one remaining discrepancy now is when the effect is triggered. In Windows 7, the effect is triggered upon releasing the mouse button, whereas using your script, it's triggered after x amount of time. The problem with that is with too short of a time period it can be jerky, and too long can make it seem unresponsive. Generally I find it behaves somewhat erratically.
I think adding a while loop and one if statement we might be able to better emulate Aero Snap functionality.
(Pseudo Code)
if (mouse button is down)
{
>>>>while (mouse button is down) -> Do nothing
>>>>if (mouse is still on or close to the edge)
>>>>>>>>maximize Active Window to the left
}
else -> Do nothing
I think that could work. The only thing I'm unsure about is the second if statement I added. I assume it's possible because Edge Bindings exist, but I have no clue how to bash script it.
Edit: So I found out adding the while loop works quite well for activating the snap on mouse release. As for the second if statement, I'm not sure how to implement it. xinput gives you some type of x/y coordinates so I imagine with grep magic and knowing the screen resolution something could be done. But there's got to be an easier/better solution here.
Last edited by arrow.69; April 30th, 2010 at 11:15 AM. Reason: Tried it out
If anyone's interested, here's my implementation of gotinsanity's script. So far I've found my adjustments make it slightly more intuitive. However, it also requires an extra terminal utility (xdotool), and because, for the right-most snap, my screen resolution is hard-coded, it's not as portable. Maybe someone more knowledgeable could improve it.
In any case, here it is:
For compizsnap-left.sh:
Code:#!/bin/sh if (/usr/bin/X11/xinput --query-state 11 | grep down) then while (/usr/bin/X11/xinput --query-state 11 | grep down) do echo 'test' done if (xdotool getmouselocation | grep x:[0-7][[:space:]]) then WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,0,0,$HALF,-1 else exit 1 fi else exit 1 fi
compizsnap-right (notice grep x:143[3-9] is exclusive to 1440x900 screen resolution)
Code:#!/bin/sh if (/usr/bin/X11/xinput --query-state 11 | grep down) then while (/usr/bin/X11/xinput --query-state 11 | grep down) do echo 'test' done if (xdotool getmouselocation | grep x:143[3-9][[:space:]] then WIDTH=`xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x'` && HALF=$(($WIDTH/2)) && wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -b add,maximized_vert && wmctrl -r :ACTIVE: -e 0,$HALF,0,$HALF,-1 else exit 1 fi else exit 1 fi
Finally, compizsnap-max:
Code:#!/bin/sh if (/usr/bin/X11/xinput --query-state 11 | grep down) then while (/usr/bin/X11/xinput --query-state 11 | grep down) do echo 'shawty' done if (xdotool getmouselocation | grep y:[0-7][[:space:]]) then wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz else exit 1 fi else exit 1 fi
That's it!
Bookmarks