Page 5 of 16 FirstFirst ... 3456715 ... LastLast
Results 41 to 50 of 158

Thread: Aero Snap function?

  1. #41
    Join Date
    Nov 2009
    Location
    USA
    Beans
    22
    Distro
    Ubuntu

    Thumbs down Re: Aero Snap function?

    Quote Originally Posted by manoriax View Post
    I really like that, but I have one question: Is there a way to only activate the plugin at the time I really move a window to one of the sides of the desktop? The problem is that as soon as I move my mouse cursor to the left or the right (without having window selected) the currently active window resizes.
    This is exactly the same problem that I'm having, and unfortunately its causing me to not use the Aero Snap function. Can anyone come up with a solution?

  2. #42
    Join Date
    May 2008
    Location
    Greece/Athens
    Beans
    965
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Aero Snap function?

    Quote Originally Posted by Hund View Post
    I would like to have a function like "Aero Snap" found in Windows.

    http://www.youtube.com/watch?v=TbsnbjkrWus

    Would be nice if Compipz had a plugin for this. But I cant find any info about it.

    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)

  3. #43
    Join Date
    Jan 2008
    Beans
    64

    Re: Aero Snap function?

    Quote Originally Posted by ShawnB391 View Post
    This is exactly the same problem that I'm having, and unfortunately its causing me to not use the Aero Snap function. Can anyone come up with a solution?
    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:

    Code:
    if X11InputEvent.clicked = true {
       execute resize command;
    } else {
      // do nothing
    }
    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 --maximize

    I will work more on it tommorow since its my day off

  4. #44
    Join Date
    Jan 2008
    Beans
    64

    Re: Aero Snap function?

    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.

    Code:
    #!/bin/sh
    
    if [ xinput --query-state 11 | grep down ] then
            wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
    else
            exit 1
    fi
    the xinput line needs to be set to the id of your mouse (just run "xinput list" to find it out)
    Last edited by gotsanity; April 29th, 2010 at 05:48 AM. Reason: edited for typos

  5. #45
    Join Date
    Jan 2008
    Beans
    64

    Lightbulb Re: Aero Snap function?

    Fixed! Snap on grabbed windows only!

    First open a terminal and type:
    Code:
    xinput list
    make a note of your mouse's ID# and execute a few more commands:
    Code:
    cd
    mkdir .scripts
    cd .scripts
    Create the following three files (DON'T FORGET: MOUSE="11" needs to be changed to your mouse's id# in all three files):

    compizsnap-left.sh
    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.
    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-right.sh
    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.
    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
    compizsnap-max.sh
    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
    Now, Fire up Settings > Preferences > CompizConfig Settings Manager and then select the Commands plugin.

    Set Command 0:
    Code:
    sh ~/.scripts/compizsnap-left.sh
    Set Command 1:
    Code:
    sh ~/.scripts/compizsnap-right.sh
    Set Command 2:
    Code:
    sh ~/.scripts/compizsnap-max.sh
    And last of all select the Edge Bindings tab and set the appropriate commands to the appropriate edges.

    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.

  6. #46
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Aero Snap function?

    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.

  7. #47
    Join Date
    Jan 2008
    Beans
    64

    Re: Aero Snap function?

    Quote Originally Posted by stinkeye View Post
    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?
    because you are telling the sh command to execute the script (at least thats how I understand it)

  8. #48
    Join Date
    Oct 2007
    Beans
    Hidden!

    Re: Aero Snap function?

    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!

  9. #49
    Join Date
    Mar 2009
    Beans
    41

    Post Re: Aero Snap function?

    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

  10. #50
    Join Date
    Mar 2009
    Beans
    41

    Re: Aero Snap function?

    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!

Page 5 of 16 FirstFirst ... 3456715 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •