Redone "compiz" aero snap

Hello! I'm new to this Linux thing but I think I have my first little contribution!!
I was using this CompizSnap script to emulate Aero snap window resizing on my desktop. (http://mikesubuntu.com/2010/06/snap-win … ng-compiz/)
I'm not sure if there is a different script but I didn't like how you had to select a mouse input ahead of time and the one I use would change as I move my laptop around and it would only work on whichever one it was set to and it was set in a handful of files. I think I fixed that (at least on my setup). Then I reorganized them into single files (controlled by argument) instead of different ones for left,right,top and changed a few things. I was trying to get data extractions to be performed in one command/process. I'm not sure if it's even better and I'm vaguely aware of some bad practices that I theorize may make it run significantly slower (still ~instant of course). Specifically, .*? pattern matching. But I hardly know what I'm doing so it's a work in progress for now! Any input on how to make it better is hella appreciated!
Alright so check this out. Two files: One to resize windows and one that triggers the resize windows script if the mouse is let go while still on the edge of the screen (initially triggered by compiz for me, setup through commands/edge/key bindings). The path of the resize script has to be set in the first one-- is there a better way to do that? I thought about using relative pathing but that seems wrong.
snap_window:
#!/bin/sh
# this script attempts to replicate the window snap function from windows!
# aka resizes the active window to the left half, the right half, or maximizes.
# commonly triggered by moving a window to the edge of the screen or
# by pressing something like <super><arrow>
# the original script that provided this is CompizSnap and the only thing I did
# was rearrange some things to use one file with arguments instead of separate
# files.
# CompizSnap is a collaborative project from ubuntuforums.org and is free
# software. This script adds window snapping functionality to compiz using the
# commands plugin.
# http://mikesubuntu.com/2010/06/snap-windows-to-sides-like-windows-7-using-compiz/
width=$( xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x' )
half=$(( ( $width / 2 ) - 10 ))
case "$1" in
left)
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
right)
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
*) # maximize
wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
esac
snap_window_wait_for_mouse:
#!/bin/sh
# this is a modified version of compiz snap that attempts to work on every
# connected mouse instead of a single one.
# original:
# http://mikesubuntu.com/2010/06/snap-windows-to-sides-like-windows-7-using-compiz/
border_threshold_px=10
mice=( $(xinput list | # list of all input devices
awk ' /Virtual core pointer/ {flag=1;next} # next two lines constrain
/Virtual core keyboard/ {flag=0} # to just mice
flag{
# the mice lines might look like:
# â¡ Virtual core pointer id=2 [master pointer (3)]
# tear this into...
split($0,id_to_end,"="); # 2 [master pointer (3)]
split(id_to_end[2],id," "); # 2
print id[1]
for mouse in ${mice[@]}
do
if /usr/bin/xinput --query-state "$mouse" | grep down
then
while( /usr/bin/xinput --query-state "$mouse" | grep down )
do
sleep 0.05
done
# check if mouse is still at a border when released
read x y <<< $( xinput --query-state $mouse |
sed -n 's/valuator\[[01]\]=\([0-9]\+\)$/\1/p' )
screen_x=$( xdpyinfo |
sed -n 's/.*dimensions:\s*\([0-9]\+\)x.*/\1/p' )
if [ $x -le $border_threshold_px ]
then
elif [ $y -le $border_threshold_px ]
then
elif [ $x -ge $(( screen_x - border_threshold_px )) ]
then
else
exit 0
fi
sh /usr/local/bin/window_snap/snap_window $1
exit
fi
done
The way I personally have it configured is I put the files in /usr/local/bin/window_snap/ and set the compiz custom commands (top left menu icon in ccsm) to:
sh /usr/local/bin/window_snap/snap_window_wait_for_mouse left
sh /usr/local/bin/window_snap/snap_window_wait_for_mouse right
sh /usr/local/bin/window_snap/snap_window_wait_for_mouse max
sh /usr/local/bin/window_snap/snap_window left
sh /usr/local/bin/window_snap/snap_window right
sh /usr/local/bin/window_snap/snap_window max
I then set the first 3 to edge bindings to be triggered when a window is dragged to the edge of the screen and then the next 3 to <super>{<left>,<right><up>}
Same dependency on wmctrl.
My Problems
I don't really know when to to prefer sed vs. awk. awk seems to get strange when you do stranger data extraction but it is scriptable so I think there is a lot of expressive power there for other uses. I was trying (atm unsuccessfully) to make sed quit after it found the first match instead of searching the rest of the string (e.g. for finding the screen x resolution).
The previous scripts solution was:
width=$( xdpyinfo | grep 'dimensions:' | cut -f 2 -d ':' | cut -f 1 -d 'x' )
and my try was:
screen_x=$( xdpyinfo | sed -n 's/.*dimensions:\s*\([0-9]\+\)x.*/\1/p' )
The other one was getting the mice xinput ids from "xinput list". I eventually chose to use only awk but before I used both awk and sed but felt that was cheating.
mice=( $(xinput list | # list of all input devices
awk ' /Virtual core pointer/ {flag=1;next} # next two lines constrain
/Virtual core keyboard/ {flag=0} # to just mice
flag{
# the mice lines might look like:
# â¡ Virtual core pointer id=2 [master pointer (3)]
# tear this into...
split($0,id_to_end,"="); # 2 [master pointer (3)]
split(id_to_end[2],id," "); # 2
print id[1]
mice=($(xinput list | awk ' /Virtual core pointer/ {flag=1;next} /Virtual core keyboard/ {flag=0} flag{ print $0 }' | sed -r 's/.*?id=([0-9]+).*?$/\1/g'))
Hope someone thinks its neat or something!

Ubuntu uses compiz. Well, Unity is (was?) a compiz plugin. You could boot a Ubuntu live medium, run ccsm and try to figure out how Ubuntu implements snapping like that.
Last edited by lucke (2013-12-04 13:36:07)

Similar Messages

  • Aero Snap, snapped

    Hi there.
    My problem is: I have something that I can't figure out what it is that makes all my windows behavior like Aero Snap. That is, if I drag any window to the top or both sides of the screen they resize according to Aero Snap-like behavior. This thing really ****** me off and I can't make it disappear. I don't have any app with that feature installed (I suspected of TotalFinder but it still happening even after removing it). I actually made a clean install a few days ago and the only thing I can think of its some preference synced from Mobile Me since I tried Cinch (which does it) before.
    Also, If I deactivate access for assistive devices on the Universal Access Pref pane it stops but it doesn't solve my problem since I may need this option activated for other things.
    I'd appreciate any help.

    Also, If I deactivate access for assistive devices on the Universal Access Pref pane it stops but it doesn't solve my problem since I may need this option activated for other things.
    That is most likely because the program uses Universal Access to control the windows.
    Look in your username/Library/StartupItems, /LaunchDaemons, and /LaunchAgents folders and also in the main /Library folder for something related to the program in question. In startupItems, it will be a folder. In the others it will be a .plist file.

  • Aero Snap equivalent on the Mac?

    Hi I find the Aero Snap feature to be very useful on Windows 7. I've searched and haven't found much info regarding this. is there an Aero Snap equivalent for the Mac? I find myself alot of times needing 2 windows side by side when I'm on my Mac. Any software that does exactly what I'm looking for? Thanks

    I don't think you searched very hard.
    File Sheriff
    XFolders
    muCommander
    PathFinder
    FinderDupe
    Fiwi
    Simple Window Sets
    TwoUp
    At VersionTracker or MacUpdate.

  • Windows 7 Aero Snap Feature - how to disable this?

    We have Thinkpads in our environment and I cannot seem to disable the Windows 7 Aero snap feature. I went into control panel, Ease of Access Center and made the change, but this does not seem to disable the aero snap feature. Any ideas?

    If you have done THIS
    And it doesn't work,
    Maybe try HERE for more tips.
    At you own risk, of course!

  • Gnome Tiling Kde / Aero Snap like

    I would like my windows to snap to full size when dragged to the top, and halfsize when dragged to either side.
    How can I do this in gnome without using compiz-fusion?

    kmason wrote:
    Wait, you can do this with compiz-fusion?
    Sorry I can't help much, just curious about the above.
    http://wwww.ubuntuforums.org/showpost.p … stcount=45

  • What DE/Wms support Aero Snap natively ?

    I've always been a GNOME user, but like lots of users Iately I start feeling annoyed by some things in GNOME 3. So I'm starting testing other DEs, and I realize I'm really dependent on the window snap feature.
    What DE/WMs support it out of the box ?

    It bears mentioning that this feature is just a (very) basic approximation of what you get with a tiling window manager
    I've used wmii for quite a few years now, and I was overjoyed when I saw the 'snap' feature in Windows 7 -- finally, I could be slightly less annoyed when using the workstations at the university!
    ...but it's still nothing compared to a tiling wm. I like knowing exactly where the next window will appear, and not having to spend any time dragging windows around

  • [Solved] Xfce4 Aero Snap

    Gnome3 has it too, unfortunately it is lacking in customization. So is there anything like this for xfce4, without using keyboard shortcuts, or compiz?
    Last edited by *vitali* (2011-05-27 02:49:15)

    There's xfwm4-tiling in the AUR.
    Here's video of it in action.
    http://www.youtube.com/watch?v=sAc6vc93jxc

  • Windows 7 Areo/Aqua Snap won't snap Reader X

    Hi,
    I just downloaded Adobe Reader X and the Windows 7 snap functionality won't work with it.  It works for all other applications so I think it's an issue with the Reader. Am I missing something?
    I don't think it should matter, but I'm using AquaSnap instead of the default AreoSnap: http://www.nurgo-software.com/products/aquasnap.

    You can tell that this is an AquaSnap issue simply as right clicking the AquaSnap systray icon and disabeling it makes Reader X follow Aero Snap again perfectly.
    AquaSnap needs to add a blacklist option for some applications.

  • Snapping Problem with Desktop Skype on Windows 10.

    First of all I want to make one thing clear: I am NOT talking about Aero Snap.
    I am talking about the automatic ability of Desktop Skype to snap to a screen corner when it is close enough to the screen corner.
    Since Microsoft has made window borders invisible in Windows 10 (Without actually removing them), Desktop Skype looks very odd when snapped. It still behaves as if the window border was visible and so we see a gap between Skype window's edge and screen's edge when Skype is snapped. I know this isn't a very huge issue, but it would still be nice if you patched this gap out.

    This also came up in this thead:
    http://community.skype.com/t5/Windows-desktop-client/Disable-snap-to-edge/td-p/3838517 I'll add my +1 here too. Also experiencing this issue, it's driving me a little mad. xD

  • Windows Key Arrow Keys Shortcut?

    Hello!
    Installed Windows 10 a few days ago and the Win+Arrow shortcut was working but has stopped working. Both the Windows key and the arrow keys function independently and my Ease of Access Mouse settings are proper in terms of Aero Snapping windows and checkboxes
    and stuff. Also I insured that Turn off Windows+x HotKeys in the Local Policy Editor wasn't enabled. I'm not sure if I'm just reporting this or asking for a solution or what, but I mean it'd be cool if I could arrange windows again. If anyone needs any
    other information just ask.
    Thank you.

    Hi,
    Snapping Windows with Win + Arrow keys worked on my test machines. Some folks have shared that it won’t work in the Windows 10 Technical Preview 9860 version. Even after a restart, it would came back and won’t work again after a while.
    Another  thing is please make sure we have installed the additional updates after we update to Windows 10 Technical Preview 9860.
    KB3010668 and KB3008956. Go to PC settings ->Update and Recovery -> Windows update, click check for updates and then install if available.
    For the Windows keyboard shortcut not working properly, we have another thread here:
    snap assist doesnt work on build 9860
    By now there seems no workaround to resolve this issue. Please wait for the future builds.
    Best regards
    Michael Shao
    TechNet Community Support

  • Why my windows 7 when i move up expands to full screen

    My computer HP Intel core 64 bit professional, when I move my windows to the top of the screen it automatically expands to full screen, sometimes I want to use another window and i cant, that is annoying, how to avoid that.
    This question was solved.
    View Solution.

    Welcome the forum, Angelitos.
    You may have Aero Snap turned on.  You can disable the feature.
    See the following document:
    HP PCs - Windows 7 Accessibility Options - c03543992
    Scroll down the document a bit more than halfway;
    See the Section titled:  Disabling Aero Snap
    You might reboot / restart the computer after making the change.
    More information:
    HP Notebooks - Using the Aero Graphics Option (Windows 7) - c01857680
    That should do it.
    Kind Regards,
    Dragon-Fur

  • Programs randomly minimizing on windows 8.1

    Hello would someone please let me know what the solution to this issue...?  The programs are randomly minimizing, word, excel, IE, on my widows 8.1 laptop.  It occurs in desktop mode and when I open word, excel from the 8.1 screen.  I have
    disabled Aero Snap.  The threads on the previous posts have a lot of bickering etc.
    Thank you.

    Hello TAC325,
    Have you made any changes before this issue?
    If my understanding is right, all programs both desktop app and metro app will randomly minimize themselves. How about the Windows explorer and Control panel?
    Do you mean all apps minimize at the same time or one app one time? Please share us a screenshot if you willing to.
    Please take the following steps for troubleshooting:
    1. As this is a laptop, please check if the mouse flickering caused by the touchpad. Please update the touchpad driver to the last version from the manufacturer website and check if this issue still exists.
    2. Unplug the mouse and check if this issue still exists
    3. Run the Anti-virus software to scan malware.
    Best regards,
    Fangzhou CHEN
    Fangzhou CHEN
    TechNet Community Support

  • Dragging a window maximises it

    I am running Windows 7 x64.
    Recently, an issue has arisen where any time I drag a window (browser, windows explorer, office etc) the window will maximise.
    THIS IS NOT AERO SNAP!!! This happens when I drag a minimised window into any part of the screen.
    Screenshot: http://i.imgur.com/rtqc0PZ.png
    In the screenshot, you will notice that there are 2 numbers on the screen, green and white. I am fairly sure that the white one is caused by my AMD Catalyst Software, but I have had this installed long before the issue started occurring.
    The green number is new, and I am pretty sure its causing the problem, as it and this issue started happening at the same time.

    A32
    Have you tried removing the CCC and leaving just the driver?  HAve you tried re-installing all the software?
    Wanikiya and Dyami--Team Zigzag

  • (Mountain)Lion Window Manager Questions

    I've written a couple apps for iOS, but nothing major. And now I have a goal of writing my own window manager for OS X. Mainly because I find developing in XCode painful after using Windows Aero/Snap features. Yes, I know about several good existing window managers, but this project seems like a good way to get my feet wet in the Apple OS development arena. I've been Googling around for about an hour looking for answers to these questions, but I'm still not 100% sure on any of them. Here goes:
    What is the name for the default Lion / Mountain Lion Window Manager?
    X11/Quartz can be restored in 10.7+ to run "legacy" OS X apps. Does that have an effect on the existing window manager?
    Are there any open source projects that I could look at to get a handle on the concepts behind the Mac OS X 10.7+ system management?

    Roguish wrote:
    Why not? I know tons of stuff applicable to Windows, I'd like to know more about Mac OS.  And the best teacher is experience in my opinion.
    But writing something like a window manager is hard. Wouldn't you rather start off slowly?
    "Snap" is a rather convienient window resizing feature of Windows 7.
    I have Windows 7 for running IE 9 to test web sites. It is dog-slow to I avoid it whenever possible.
    XCode isn't my problem, the minimalistic window controls in Mac OS X are my problem.  But I only have to deal with them in an irritating fashion when I'm coding in XCode
    Xcode is pretty-much an all-encompassing environment. You should only have one Xcode window open. Source files are in the editing pane.
    I just didn't want to start a flame war over operating systems.  I personally don't have an OS preference; if an application I need is only on Mac OS then I'll use Mac OS, if I need to write a document I'll use Word in Win7, if I need to rapidly prototype a script for research purposes I'll use Ubuntu.
    This is not Ars or Slashdot. This is Apple-land. Macs rule - end of story. If you try some Mac apps, you might find that Pages does anything Word does three times faster and OS X does anything Ubuntu does, only better.
    It's a free country.  Could you suggest a better one besides the developer tutorials in the Mac Developer Library?  I've written a couple drivers using it, but I can't seem to find the correct wording to locate the current topic in there.
    No, it isn't. As I said above, this is Apple-land. You asked about a good project to get your feet wet in the Apple OS development arena. Anything involving X11 would be a very poor project for that purpose because it would not teach you one thing about Apple OS development. If you want to learn about X11, then do something in X11. If you want to write a Mac application, then do that.
    Really? What would you call Mission Control then (I finally succeeded with Google)?
    You are talking X11-isms. You aren't going to replace Mission Control.
    How about Inkscape, the free SVG editor?  Which is still in active development.  And as of this post requires Quartz to create an X11 window to run in.  I'm sure they'll get to updating it eventually, but until then I'd rather not shell out for Illustrator just to make SVG's quickly.
    Adobe is not really a Mac development house anymore. They just churn out ugly, expensive cross-platform bloatware. Adobe's idea of an icon is a square with an "A" in it.
    If you are looking for quick and easy to use vector drawing tools, the Developer forum might not be the right place to ask. I use Logoist. It's not free but I can create documents faster than you can download and launch Inkscape.
    Or maybe you just aren't familiar with what "Window Manager" means.
    I know what a "Window Manager" is. If you want to ask something specific, please do so.
    I want to code an application for OS X that would allow me to very quickly resize the active window to take up the right half of my screen by pressing command+<right arrow> (or something similar).
    Was that so hard?
    The only shortcuts similar to what I want (that I use) are command+m (minimize) and command+<down arrow> (open current selection using the default app). Three existing window managers that I know of that seem promising and have nice feature sets are SizeUp, Cinch, and Optimal Layout.  But as I mentioned earlier I want to code it myself. As an exercise. To learn.
    You could cobble together some AppleScript such as you have already posted. However, that isn't going to teach you anything about OS X development either.
    Next time could you be a little less smug (and a lot more helpful) when replying to an obviously new member to the forums?
    Only if you meet me halfway. What kind of welcome would I get if I showed up in a Windows forum asking how I could learn about .NET by writing a Linux device driver? And then, for good measure, I call Visual Studio painful because it doesn't support some Mac features that Windows users have never heard of.
    This is a different world. There are no window managers and there never have been. Asking about X11 in OS X is like asking about DOS development in Windows. Sure, there are some people who still do that stuff, but I would never suggest anyone start there. X11 is just part of the UNIX compatibility layer - a foreign add-on. Most of the open source is in that layer too. If by "open source" you mean "free software", you should know that free software is pretty much incompatible with the Apple ecosystem and not by Apple's decision.
    I suggest you start by writing some applications. Use the Xcode project templates in File > New > Project > Cocoa Application. If you want to start on the command line, do File > New > Project > Command Line Tool > Foundation. Get used to Cocoa and Objective-C.

  • Aero Flip 2D stopped working

    The Aero Flip 2D does not work anymore although the Flip 3D does . When I press Alt+Tab I only see the classic list of active tasks:
    And I cannot use the directional keys to select a task.
    Facts about the problem:
    Only one user account is affected.
    The Desktop Composition is active .
    Ctrl + Alt + Tab does not work.
    Ctrl + Win + Tab works and shows the Flip 3D .
    All other Aero effects work well: Flip 3D, Snap, Shake, Peek, ...
    Verifications that have already been made:
    $> chkdsk /f c:
    Aero troubleshooting.
    $> sfc /verifyonly
    $> gpedit.msc   . Nothing prevents Aero from working properly.
    All the relevant services are active: DWM, Themes.
    $> eventvwr -> Logs -> Application. The Desktop Windows Manager did not generate any important events related to the problem.
    None of the verifications above has detected any problem.
    I have been using Desktops 2.0 since a few weeks ago. Deactivating Desktops did not solve the problem .
    I will only create another user account as a last resort, so I hope someone can help me.
    To informatize is necessary; follow me the good.

    aharrell905,
    I'm sorry to hear about your phone! It does appear that there may have been a hardware concern happen. We likely have several options, including the manufacturer warranty. The warranty covers these sort of situations for 12 months after the original purchase of the device. The account may have an available upgrade, too! If you need assistance with reviewing your account for options, please direct message me.
    Thank you!

Maybe you are looking for

  • How can change the created date on a photo?

    Hi I have imported photos that were originally taken in summer 2002 (and where dated as such), now they have been imported to iPhoto, the created and modified dated have changed to the date I imported them (14th Sept 06), therefore they are now sitti

  • Associated Items Field in SharePoint 2013

    Hi , I have two custom lists :       -  Products List  which contains the list of products ( child list)        - Products Category List which contains the list of categories ( parent list)       - A lookup column in the Products List which point to

  • No business interface, component interface or web service endpoint interface found for Session Bean SessionEJB

    hi , i am just using EJb in my Application just created an SessionBean and with Local interface in it i am getting this wierd exception with weblogic NetBeans and eclipse also weblogic.ejb.container.compliance.ComplianceException: No business interfa

  • Frames in file starting near t are not encoded at 24p

    I get this message when i capture video at 29.97 and try to use the tools>remove advance pulldown. It works fine with I capture a little bit at a time, when I try to capture the whole tape I get this error, when I try capturing using the 2:3:3:2 pres

  • How to extract struck up LUW from R/3

    Hi, I am monitoring the process chain, But it failed. Because so many LUW are struck in R/3. So how can I extract those struck up LUW's from R/3 from different extractors.