Created
January 24, 2022 02:03
-
-
Save kborling/417662a0b0607cc2050c81ff0e089619 to your computer and use it in GitHub Desktop.
Window Movements
This file contains hidden or 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/sh | |
# Move a window to the side of a screen. | |
case "$1" in | |
"left") xdotool getactivewindow windowmove 0 y ;; | |
"top") xdotool getactivewindow windowmove x 0 ;; | |
"right") | |
screen_width=$(xwininfo -root | grep Width | cut -d: -f2 | tr -d ' ') | |
win_width=$(xdotool getactivewindow getwindowgeometry --shell | grep WIDTH | cut -d= -f2) | |
xdotool getactivewindow windowmove $(( $screen_width - $win_width )) y | |
;; | |
"bottom") | |
screen_height=$(xwininfo -root | grep Height | cut -d: -f2 | tr -d ' ') | |
win_height=$(xdotool getactivewindow getwindowgeometry --shell | grep HEIGHT | cut -d= -f2) | |
xdotool getactivewindow windowmove x $(( $screen_height - $win_height )) | |
;; | |
"center") | |
screen_height=$(xwininfo -root | grep Height | cut -d: -f2 | tr -d ' ') | |
screen_width=$(xwininfo -root | grep Width | cut -d: -f2 | tr -d ' ') | |
win_height=$(xdotool getactivewindow getwindowgeometry --shell | grep HEIGHT | cut -d= -f2) | |
win_width=$(xdotool getactivewindow getwindowgeometry --shell | grep WIDTH | cut -d= -f2) | |
xdotool getactivewindow windowmove x $((( $screen_height / 2 ) - ($win_height / 2))) | |
xdotool getactivewindow windowmove $((( $screen_width / 2 ) - ($win_width / 2))) y | |
;; | |
"center-x") | |
screen_height=$(xwininfo -root | grep Height | cut -d: -f2 | tr -d ' ') | |
win_height=$(xdotool getactivewindow getwindowgeometry --shell | grep HEIGHT | cut -d= -f2) | |
xdotool getactivewindow windowmove x $((( $screen_height / 2 ) - ($win_height / 2))) | |
;; | |
"center-y") | |
screen_width=$(xwininfo -root | grep Width | cut -d: -f2 | tr -d ' ') | |
win_width=$(xdotool getactivewindow getwindowgeometry --shell | grep WIDTH | cut -d= -f2) | |
xdotool getactivewindow windowmove $((( $screen_width / 2 ) - ($win_width / 2))) y | |
;; | |
*) | |
echo "Unsupported: \"$1\"" | |
exit 1 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment