Skip to content

Instantly share code, notes, and snippets.

@wallacesilva
Created June 28, 2018 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallacesilva/3f2aae1da99fc0fbcd1fe354faf6a35e to your computer and use it in GitHub Desktop.
Save wallacesilva/3f2aae1da99fc0fbcd1fe354faf6a35e to your computer and use it in GitHub Desktop.
Resize window active/focused with this script - [INCOMPLETE]
#!/bin/bash
# Wallace Silva - wallacesilva.com
dothis=true
toW=720
toH=560
nowW=0
nowH=0
increment=1
while [ dothis ]
do
nowW=$(xdotool getwindowfocus getwindowgeometry | sed -n '3,30p' | cut -d ':' -f 2 | xargs | cut -d 'x' -f 1)
nowH=$(xdotool getwindowfocus getwindowgeometry | sed -n '3,30p' | cut -d ':' -f 2 | xargs | cut -d 'x' -f 2)
ratioW=$(((toW-nowW)/100))
ratioH=$(((toH-nowH)/100))
echo "Ratio // W: $ratioW / H: $ratioH"
if [ "$nowW" -lt "$toW" ]; then
# nowW=$((nowW+increment))
nowW=$((nowW+ratioW))
fi
if [ "$nowH" -lt "$toH" ]; then
# nowH=$((nowH+increment))
nowH=$((nowH+ratioH))
fi
sleep 0.1 && wmctrl -r :ACTIVE: -e 0,300,168,$nowW,$nowH
if [ "$nowW" -ge "$toW" ] && [ "$nowH" -ge "$toH" ]; then
dothis=false
fi
# can be better
if [ $dothis ]; then
doNothing=0
echo "NOW // W: $nowW / H: $nowH"
echo "TO // W: $toW / H: $toH"
else
exit
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment