Skip to content

Instantly share code, notes, and snippets.

@wallacesilva
Created June 28, 2018 17:47
Show Gist options
  • Select an option

  • Save wallacesilva/3f2aae1da99fc0fbcd1fe354faf6a35e to your computer and use it in GitHub Desktop.

Select an option

Save wallacesilva/3f2aae1da99fc0fbcd1fe354faf6a35e to your computer and use it in GitHub Desktop.

Revisions

  1. wallacesilva created this gist Jun 28, 2018.
    50 changes: 50 additions & 0 deletions resize window linux x11
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    #!/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