#!/bin/sh # bspcDirectionFocus.sh: Directionally select node with same floating state # # Usage: bspcDirectionFocus.sh DIRECTION usageMessage="Usage: bspcDirectionFocus.sh DIRECTION" direction="$1" if ! echo "$direction" | grep -Eq '(west)|(south)|(north)|(east)'; then echo "$usageMessage" 1>&2 exit 1 fi nodeStatus="$(bspc query -T -n)" desktopStatus="$(bspc query -T -d)" # If selected window is floating select floating in direction. # Else if layout is monocle and west or east select previous or next local window in direction. # Else select non-floating in direction. if echo "$nodeStatus" | grep -q '"state":"floating'; then bspc node --focus "$direction".floating elif echo "$desktopStatus" | grep -q '"layout":"monocle"'; then if [ "$direction" = "west" ]; then bspc node --focus prev.local.window.!floating elif [ "$direction" = "east" ]; then bspc node --focus next.local.window.!floating fi else bspc node --focus "$direction".!floating fi