Protesilaos Stavrou
Philosopher. Polymath.

Sample of a BSPWM resize method

I was asked to provide some information on how to resize a floating window in BSPWM. Here is a skeleton of a solution.

Please note that I have no time to expand on this, as I no longer use BSPWM. I am exclusively focused on Emacs right now. Of course the book I published on the matter is still relevant and should work perfectly fine—I was running that setup for about 2 years!

The shell script

Here is the basic code. Place it in a file called bspwm_resize or something appropriate (and make it executable and add it to your PATH).

If you need to limit it to floating windows, you could use a check for bspc query -N -n .floating.

#!/bin/bash

[ "$#" -eq 3 ] || { echo "Needs exactly three arguments."; exit 1; }

motion="$1"
direction="$2"
size="$3"

if [ "$motion" = 'expand' ]; then
	# These expand the window's given side
	case "$direction" in
		north) bspc node -z top 0 -"$size" ;;
		east) bspc node -z right "$size" 0 ;;
		south) bspc node -z bottom 0 "$size" ;;
		west) bspc node -z left -"$size" 0 ;;
	esac
else
	# These contract the window's given side
	case "$direction" in
		north) bspc node -z top 0 "$size" ;;
		east) bspc node -z right -"$size" 0 ;;
		south) bspc node -z bottom 0 -"$size" ;;
		west) bspc node -z left "$size" 0 ;;
	esac
fi

The commands for the key bindings

Then in your SXHKD file, you can use standard keys of your choice or the less known “continuous input” technique. I prepared a demo for the latter. This specific mode is denoted by the colon sign :.

What it does: you enter the “mode” with the keys to the left of the colon and then you execute the relevant commands by just pressing what is to the right of the colon. So there is no need to continuously press the entire sequence.

Exit the “mode” with the Escape key.

super + e : {h,j,k,l}
    bspwm_resize expand {west,south,north,east} 50

super + shift + e : {h,j,k,l}
    bspwm_resize contract {west,south,north,east} 50

Closing thoughts

I never developed something specifically for floating windows, because I rarely used them. And when I did, it was usually something involving the mouse, at which point it was okay to just resize them with Alt+Right click drag, or move them the same way with Left click.

That covers it. Hopefully it gives you something to work with. If you need help, please contact me (or just check the book I linked to—it is free of charge and copyleft).