Created
March 31, 2009 16:02
-
-
Save andrewmcdonough/88246 to your computer and use it in GitHub Desktop.
A bash script to move the focused window in X to different parts of the screen. Most useful when you assign shortcut keys to the various options, e.g. assign '<Super>Up' to run 'swind up'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Written by Andrew McDonough | |
# Prerequisites: xdotool must be installed and in your path (http://tinyurl.com/xdotool) | |
# A simple bash script that uses xdotool to move the window that is currently in focus to different parts of the screen. | |
# Particularly useful for reading web pages with flexible layouts on wide monitors. | |
# Assign the various options to keyboard shortcuts e.g. '<Super>Left' assigned to 'swind left' | |
# See http://tinyurl.com/ubuntukeys for help with assigning keyboard shortcuts. | |
# Change the following to suit your own monitor's resolution. Mine is 1920x1200 | |
width=1920 | |
height=1200 | |
winid=`xdotool getwindowfocus` | |
case "$1" in | |
'') | |
echo "Usage: swind <left|right|top|bottom|top-left|top-right|bottom-left|bottom-right>" | |
;; | |
'left') | |
xdotool windowmove $winid 0 0 | |
xdotool windowsize $winid $(( $width/2 )) $height | |
;; | |
'right') | |
xdotool windowmove $winid $(( $width/2)) 0 | |
xdotool windowsize $winid $(( $width/2)) $height | |
;; | |
'top') | |
xdotool windowmove $winid 0 0 | |
xdotool windowsize $winid $width $(( $height/2 )) | |
;; | |
'bottom') | |
xdotool windowmove $winid 0 $(( $height/2 )) | |
xdotool windowsize $winid $width $(( $height/2 )) | |
;; | |
'top-left') | |
xdotool windowmove $winid 0 0 | |
xdotool windowsize $winid $(( $width/2 )) $(( $height/2)) | |
;; | |
'top-right') | |
xdotool windowmove $winid $(( $width/2)) 0 | |
xdotool windowsize $winid $(( $width/2 )) $(( $height/2 )) | |
;; | |
'bottom-left') | |
xdotool windowmove $winid 0 $(( $width/2 )) | |
xdotool windowsize $winid $(( $width/2 )) $(( $height/2 )) | |
;; | |
'bottom-right') | |
xdotool windowmove $winid $(( $width/2)) $(( $height/2 )) | |
xdotool windowsize $winid $(( $width/2 )) $(( $height/2 )) | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this nice little wrapper around xdotool to make some convenient window moves. I found it useful. I made a quick fork with a couple additions:
https://gist.github.com/bdowling/ad87c58362af7c28806bb2292436222d