helm/os/+arch/bin/bspc.sh

53 lines
1.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
# A helper script for bspwm; makes the act of switching and swapping nodes act more
# intuitive. Also hides lemonbar on fullscreening.
if (( $# == 0 )); then
>&2 echo "Usage: $0 [f DIR|F DIR|s DIR|S DIR|m]"
exit 1
fi
cmd=$1
dir=$2
case $cmd in
m) main=$(bspc query -M -m primary)
mon=$(bspc query -M -m focused)
if [[ $main == $mon ]]; then
xdotool search --onlyvisible --classname lemonbar windowunmap || \
xdotool search --classname lemonbar windowmap
fi
bspc desktop -l next
;;
# focus
f) if ! bspc node -f "$dir.local"; then
if [[ $(bspc query -M -m "$dir") ]]; then
bspc monitor -f "$dir"
fi
fi
;;
# focus monitor
F) bspc monitor -f "$dir" ;;
# swap
s) old_id=$(bspc query -N -n focused)
if bspc node -s "$dir.local"; then
bspc node -f "$old_id"
elif [[ $(bspc query -M -m "$dir") ]]; then
bspc node -m "$dir"
bspc node -f "$old_id"
fi
;;
# swap to monitor
S) old_id=$(bspc query -N -n focused)
if [[ $(bspc query -M -m "$dir") ]]; then
bspc node -m "$dir"
bspc node -f "$old_id"
fi
;;
esac