Hi,
Can some one help me with tiling windows, either horizontaly or vertically, on a desktop?
Can some one help me with tiling windows, either horizontaly or vertically, on a desktop?
#!/bin/bash echo "" echo "Ubuntu (GNOME) contains a nice utility Compiz Grid:" echo "Tile, position and resize your windows to fit an imaginary grid." echo "The functionality is based on Winsplit Revolution for Microsoft Windows." echo "For more info, demos etc. see: [url]http://winsplit-revolution.com"[/url] echo "" echo "This script can be used to define wmctrl commands for Kubuntu (KDE)" echo "for your monitor resolution. These commands can be attached to" echo "Key Bindings (keyboard shortcuts), so you have the same functionality" echo "under KDE without the need to install a Tiling Window Manager like" echo "xmonad, awesome or ion3." echo "" echo "The commands can also be used to emulate Windows 7 Aero Snap" echo "without annoying overlapping windows." echo "For more info about this subject see youtube or for example" echo "[url]http://www.omgubuntu.co.uk/2009/11/aero-snap-ubuntu-linux.html"[/url] echo "" echo "NOTES:" echo "- This scipt uses xwininfo (part of x11-utils package) and wmctrl." echo " For (K)ubuntu:" echo " sudo apt-get install x11-utils wmctrl" echo "- This script is tested with:" echo " Ubuntu 9.10 (resolution 1920x1200)" echo " Kubuntu 9.10 (resolution 1920x1200)" echo " Kubuntu 8.10 (resolution 1600x1200)" # define maximum size of usable screen wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz sleep 1 WIDTH=$((`xwininfo -id $WINDOWID | grep 'Width:' | cut -f 2 -d ':'`)) HEIGHT=$((`xwininfo -id $WINDOWID | grep 'Height:' | cut -f 2 -d ':'`)) BORDERY=$((`xwininfo -id $WINDOWID | grep 'Corners:' | cut -f 11 -d ' ' | cut -f 2 -d '-'`)) wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz; sleep 1 wmctrl -r :ACTIVE: -e 0,0,0,$WIDTH,$HEIGHT sleep 1 BORDER=$((`xwininfo -id $WINDOWID | grep 'Absolute upper-left X:' | cut -f 2 -d ':'`)) BOTTOM=$((`xwininfo -id $WINDOWID | grep 'Corners:' | cut -f 11 -d ' ' | cut -f 2 -d '-'`)) BORDERY=$(($BORDERY-(`xwininfo -id $WINDOWID | grep 'Corners:' | cut -f 11 -d ' ' | cut -f 2 -d '-'`))) TOP=$((`xwininfo -id $WINDOWID | grep 'Relative upper-left Y:' | cut -f 2 -d ':'`)) if [ $TOP -eq 0 ] then #KDE echo "" echo "----------------------" echo "Assuming KDE, Correct?" echo "----------------------" WIDTH=$(((`xwininfo -id $WINDOWID | grep 'Width:' | cut -f 2 -d ':'`)-2*$BORDER)) HEIGHT=$(((`xwininfo -id $WINDOWID | grep 'Height:' | cut -f 2 -d ':'`)-2*$BORDERY)) TITLE=$((`xwininfo -id $WINDOWID | grep 'Absolute upper-left Y:' | cut -f 2 -d ':'`)) echo "" echo "Below are the wmctrl commands for KDE (Kubuntu)." echo "" echo "The Key Bindings (keyboard shortcuts) can be set in the following way:" echo "sudo apt-get install xbindkeys xbindkeys-config" echo "xbindkeys --defaults > ~/.xbindkeysrc" echo "echo \"xbindkeys\" > ~/.kde/Autostart/startxbindkeys.sh" echo "chmod u+x ~/.kde/Autostart/startxbindkeys.sh" echo "~/.kde/Autostart/startxbindkeys.sh" echo "xbindkeys-config" echo "finally add the commands below" echo "" echo "Centre Control+Alt+KP_Begin:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,0,$WIDTH,$HEIGHT" echo "" echo "Left Control+Alt+KP_Left:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,0,$(($WIDTH/2-$BORDER)),$HEIGHT" echo "" echo "Right Control+Alt+KP_Right:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+($BORDER))),0,$(($WIDTH/2-$BORDER)),$HEIGHT" echo "" echo "Top Control+Alt+KP_Up:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,0,$WIDTH,$(($HEIGHT/2-($TITLE/2+$BORDERY)))" echo "" echo "Bottom Control+Alt+KP_Down:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,$(($TITLE+$BORDERY+$TOP+($HEIGHT/2-($TITLE/2+$BORDERY)))),$WIDTH,$(($HEIGHT/2-($TITLE/2+$BORDERY)))" echo "" echo "Top Left Control+Alt+KP_Home:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,0,$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDERY)))" echo "" echo "Top Right Control+Alt+KP_Prior:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+($BORDER))),0,$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDERY)))" echo "" echo "Bottom Left Control+Alt+KP_End:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,$(($TITLE+$BORDERY+$TOP+($HEIGHT/2-($TITLE/2+$BORDERY)))),$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDERY)))" echo "" echo "Bottum Right Control+Alt+KP_Next:" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+($BORDER))),$(($TITLE+$BORDERY+$TOP+($HEIGHT/2-($TITLE/2+$BORDERY)))),$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDERY)))" else #GNOME echo "" echo "------------------------" echo "Assuming GNOME, Correct?" echo "------------------------" WIDTH=$((`xwininfo -id $WINDOWID | grep 'Width:' | cut -f 2 -d ':'`)) HEIGHT=$((`xwininfo -id $WINDOWID | grep 'Height:' | cut -f 2 -d ':'`)) wmctrl -r :ACTIVE: -e 0,0,$TOP,$WIDTH,$(($HEIGHT-2*$BOTTOM)) sleep 1 TITLE=$(((`xwininfo -id $WINDOWID | grep 'Absolute upper-left Y:' | cut -f 2 -d ':'`)-$TOP-$BORDER)) TOP=$(($TOP-$TITLE)) echo "" echo "Below are the wmctrl commands for GNOME (Ubuntu)." echo "The Key Bindings (keyboard shortcuts)" echo "or Edge Bindings (like Aero Snap) can be set under:" echo "System -> Prefences -> CompizConfig Settings Manager ->" echo "Commands -> Commands/Key Bindings/Edge Bindings" echo "" echo "Centre <Control><Alt>KP_5:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$BORDER,$(($TITLE+$TOP)),$WIDTH,$HEIGHT" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,0,$WIDTH,$HEIGHT" echo "" echo "Left <Control><Alt>KP_4:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$BORDER,$(($TITLE+$TOP)),$(($WIDTH/2-$BORDER)),$HEIGHT" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,0,$(($WIDTH/2-$BORDER)),$HEIGHT" echo "" echo "Right <Control><Alt>KP_6:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+(2*$BORDER))),$(($TITLE+$TOP)),$(($WIDTH/2-$BORDER)),$HEIGHT" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+(2*$BORDER))),0,$(($WIDTH/2-$BORDER)),$HEIGHT" echo "" echo "Top <Control><Alt>KP_8:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$BORDER,$(($TITLE+$TOP)),$WIDTH,$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,0,$WIDTH,$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "" echo "Bottom <Control><Alt>KP_2:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$BORDER,$(((2*($TITLE+$BORDER))+$TOP+($HEIGHT/2-($TITLE/2+$BORDER)))),$WIDTH,$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,$(((2*($TITLE+$BORDER))+$TOP+($HEIGHT/2-($TITLE/2+$BORDER)))),$WIDTH,$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "" echo "Top Left <Control><Alt>KP_7:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$BORDER,$(($TITLE+$TOP)),$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,0,$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "" echo "Top Right <Control><Alt>KP_9:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+(2*$BORDER))),$(($TITLE+$TOP)),$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+(2*$BORDER))),0,$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "" echo "Bottom Left <Control><Alt>KP_1:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$BORDER,$(((2*($TITLE+$BORDER))+$TOP+($HEIGHT/2-($TITLE/2+$BORDER)))),$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,0,$(((2*($TITLE+$BORDER))+$TOP+($HEIGHT/2-($TITLE/2+$BORDER)))),$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "" echo "Bottum Right <Control><Alt>KP_3:" #echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+(2*$BORDER))),$(((2*($TITLE+$BORDER))+$TOP+($HEIGHT/2-($TITLE/2+$BORDER)))),$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz;wmctrl -r :ACTIVE: -e 0,$(($WIDTH/2+(2*$BORDER))),$(((2*($TITLE+$BORDER))+$TOP+($HEIGHT/2-($TITLE/2+$BORDER)))),$(($WIDTH/2-$BORDER)),$(($HEIGHT/2-($TITLE/2+$BORDER)))" echo "" echo "TIP: For GNOME (Ubuntu) Key Bindings use Compiz Grid instead. Go to:" echo " System -> Prefences -> CompizConfig Settings Manager ->" echo " Window Management -> Grid" fi wmctrl -r :ACTIVE: -e 0,0,0,$WIDTH,$HEIGHT echo "" echo "Current used values:" echo "border: $BORDER pixels" if [ $TOP -eq 0 ] then #KDE echo "bordery: $BORDERY pixels" fi echo "width: $WIDTH pixels" echo "height: $HEIGHT pixels" echo "bottom: $BOTTOM pixels" echo "top: $TOP pixels" echo "title: $TITLE pixels"
Comment