Skip to content

Instantly share code, notes, and snippets.

@drasill
Created October 25, 2016 09:08
Show Gist options
  • Save drasill/d7346706ebc9eeb0e5ba1b9642f41c0f to your computer and use it in GitHub Desktop.
Save drasill/d7346706ebc9eeb0e5ba1b9642f41c0f to your computer and use it in GitHub Desktop.
bspwm: Change resize ratio of current focused node (or node's parent)
#!/bin/sh
# Get the current non-leaf focused node
NODE=$(bspc query -N -n focused.\!leaf)
if [ $? -ne 0 ]; then
# No non-leaf, then select parent of focused node
NODE=$(bspc query -N -n @parent)
fi
# Get Ratio
RATIO=$(bspc query -T -n $NODE | awk 'match($0, /"splitRatio":(0.[1-9]+)/, ary) {print ary[1]}')
# Select new Ratio
NEWRATIO=0.15
if [ $RATIO = '0.15' ]; then
NEWRATIO=0.25
elif [ $RATIO = '0.25' ]; then
NEWRATIO=0.5
elif [ $RATIO = '0.5' ]; then
NEWRATIO=0.75
elif [ $RATIO = '0.75' ]; then
NEWRATIO=0.85
fi
# Apply new ratio
bspc node $NODE -r $NEWRATIO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment