Skip to content

Instantly share code, notes, and snippets.

@nagy135
Created March 19, 2020 19:12
Show Gist options
  • Save nagy135/ee6759b913da1987937df056074bddd1 to your computer and use it in GitHub Desktop.
Save nagy135/ee6759b913da1987937df056074bddd1 to your computer and use it in GitHub Desktop.
#!/bin/zsh
wid=$1
class=$2
instance=$3
monitor=$4
desktop=$5
node=$6
if [[ "$class" == "mpv" ]]; then
desktop=$(($(bspc query -D -d --names) - 1))
target=$(wmctrl -l -G -x | grep mpv | awk -v desktop=$desktop '$2 == desktop {print $1 " " $5*$6}' | sort -k2 -n -r | awk '{print $1}' | sed 1q)
if [[ $target != '' ]]; then
width=$(wmctrl -l -G | grep $target | awk '{print $5}')
height=$(wmctrl -l -G | grep $target | awk '{print $6}')
if [[ $width -gt $height ]]; then
bspc node $target -p east
else
bspc node $target -p south
fi
bspc node -f $target
echo "state=tiled"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment