2017-01-03 00:30:51 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# A helper script for bspwm; makes the act of switching and swapping nodes act more
|
2017-01-16 19:31:36 -08:00
|
|
|
# intuitive. Also hides lemonbar on fullscreening.
|
2017-01-03 00:30:51 -08:00
|
|
|
|
2017-01-16 19:31:36 -08:00
|
|
|
if (( $# == 0 )); then
|
|
|
|
>&2 echo "Usage: $0 [f DIR|F DIR|s DIR|S DIR|m]"
|
2017-01-03 00:30:51 -08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cmd=$1
|
|
|
|
dir=$2
|
|
|
|
|
|
|
|
case $cmd in
|
2017-01-16 19:31:36 -08:00
|
|
|
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
|
|
|
|
;;
|
2017-01-03 00:30:51 -08:00
|
|
|
# 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
|