Skip to content

Instantly share code, notes, and snippets.

@aboettger
Created January 10, 2015 11:51
Show Gist options
  • Save aboettger/c367facee459f8eccde6 to your computer and use it in GitHub Desktop.
Save aboettger/c367facee459f8eccde6 to your computer and use it in GitHub Desktop.
center active window
#!/bin/bash
IFS='x' read screenWidth screenHeight < <(xdpyinfo | grep dimensions | grep -o '[0-9x]*' | head -n1)
width=$(xdotool getactivewindow getwindowgeometry --shell | head -4 | tail -1 | sed 's/[^0-9]*//')
height=$(xdotool getactivewindow getwindowgeometry --shell | head -5 | tail -1 | sed 's/[^0-9]*//')
newPosX=$((screenWidth/2-width/2))
newPosY=$((screenHeight/2-height/2))
xdotool getactivewindow windowmove "$newPosX" "$newPosY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment