Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 19/20 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 6th January 2012, 09:28 PM
geoffmen Offline
Registered User
 
Join Date: Jun 2011
Posts: 31
linuxchrome
Assigning a keyboard shortcut to "snap window to left/right half of the screen"

I want tu assign Super+Left to "snap window to left half of the screen", but I don't see such an option in the keyboard shortcuts. Is there a way I could create a custom shortcut using a Command? I've looked on the net but haven't found anything...
__________________
Fedora 16 64
Gnome 3.2
Dell XPS M1330
Intel Core2 Duo CPU T6400 @ 2.00GHz × 2
Intel 965GM
Reply With Quote
  #2  
Old 6th January 2012, 09:49 PM
WBryan Offline
Registered User
 
Join Date: Dec 2010
Posts: 8
linuxchrome
Re: Assigning a keyboard shortcut to "snap window to left/right half of the screen"

One could imagine (as I have) writing a shell script to do this, then attach a keyboard shortcut to it...

wmctrl can do some pretty cool stuff from the commandline... you just need additional window information to do this from a keyboard shortcut.

Here's one I wrote to toggle the maximize vertical and horizontal to fix a problem with compiz...
Requires:
xwininfo (xorg-X11-utils)
xdotool
wmctrl

Code:
#!/bin/bash
#
# Hack to get the desired toggle maximize vert/horiz effect in compiz
#

TYPE=$1

# Get the active window id
WINID=`xdotool getactivewindow`

# Get the upper left X (absolute)
ULX=`xwininfo -id $WINID | grep "Absolute upper-left X" | sed 's/Absolute upper-left X: //'`
MAXVERT=`xwininfo -id $WINID -wm | grep "Maximized Vert"`
MAXHORZ=`xwininfo -id $WINID -wm | grep "Maximized Horz"`

ULX=`echo $ULX | sed -e 's/^[ \t]*//'`
MAXVERT=`echo $MAXVERT | sed -e 's/^[ \t]*//'`
MAXHORZ=`echo $MAXHORZ | sed -e 's/^[ \t]*//'`

# First toggle what we want
case "$TYPE" in
    vert)
        wmctrl -r :ACTIVE: -b toggle,maximized_vert
        ;;
    horz)
        wmctrl -r :ACTIVE: -b toggle,maximized_horz
        ;;
esac


# Now move it back, if it needs to be moved back
if [ -z "$MAXVERT" ]; then
# Sleep a little... because it takes time for the window to move
    usleep 50000
    wmctrl -r :ACTIVE: -e 0,${ULX},-1,-1,-1
fi
Reply With Quote
  #3  
Old 7th January 2012, 11:28 PM
geoffmen Offline
Registered User
 
Join Date: Jun 2011
Posts: 31
linuxchrome
Re: Assigning a keyboard shortcut to "snap window to left/right half of the screen"

Thanks for the info. I created a simple script in ~/snapLeft.sh that does the trick:

WINID=`xdotool getactivewindow`
wmctrl -i -r $WINID -e 0,1,22,640,800
For the left half, and slightly different coordinates for the right half.
(Do you know what gravity is?)

However, I don't know how to run the script using the keyboard shortcut. In System Settings / Keyboard / Shortcuts / Custom Shortcuts I created one and I wrote "~/snapLeft.sh" but it fails to execute it when I do the keyboard combination. How can I assign the kb shortcut to the script?
__________________
Fedora 16 64
Gnome 3.2
Dell XPS M1330
Intel Core2 Duo CPU T6400 @ 2.00GHz × 2
Intel 965GM
Reply With Quote
  #4  
Old 9th January 2012, 02:00 PM
WBryan Offline
Registered User
 
Join Date: Dec 2010
Posts: 8
linuxchrome
Re: Assigning a keyboard shortcut to "snap window to left/right half of the screen"

I dont normally use Gnome 3... but followed what you did, and got an window popup saying there was an error with executing that script.

I replaced the
Code:
~/snapLeft.sh
with
Code:
/home/username/snapLeft.sh
and it began working as prescribed..

Try using the absolute pathname, instead of using the tilda (~).
Reply With Quote
Reply

Tags
assigning, keyboard, shortcut

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [GNOME 3] A keyboard shortcut to bring into focus the "Type to search..." window? Mariusz W Using Fedora 4 27th May 2011 10:47 AM
Fedora 10 blank screen with a "-" in the top left corner. tootal2 Using Fedora 2 27th December 2008 05:54 AM
Installation "Crash" of F9 leaves me with a Half F8 Half F9 system BobLfoot Installation, Upgrades and Live Media 7 6th August 2008 12:06 AM
Problems Binding "Open a Terminal" to keyboard shortcut jon3k Using Fedora 10 28th May 2008 01:33 AM
aterm: can't load font "snap" BellAdict Using Fedora 2 17th October 2004 01:49 AM


Current GMT-time: 22:19 (Wednesday, 16-04-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat