Skip to content

Instantly share code, notes, and snippets.

@konsolebox
Created December 5, 2022 19:12
Show Gist options
  • Save konsolebox/4ad061b41d1b653588cd1dbaf3eaa09f to your computer and use it in GitHub Desktop.
Save konsolebox/4ad061b41d1b653588cd1dbaf3eaa09f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Based on https://askubuntu.com/a/571711/415750
function main {
local screen_width screen_height WIDTH HEIGHT new_pos_x new_pos_y
read screen_width screen_height < <(xdotool getactivewindow getdisplaygeometry)
eval "$(xdotool getactivewindow getwindowgeometry --shell | grep -e WIDTH= -e HEIGHT=)"
new_pos_x=$(( screen_width / 2 - WIDTH / 2 ))
new_pos_y=$(( screen_height / 2 - HEIGHT / 2 ))
xdotool getactivewindow windowmove "${new_pos_x}" "${new_pos_y}"
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment