2017-12-05 22:39:10 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# bspc-focus
|
|
|
|
# Jump to the next window in a direction. If -m is supplied, jump to the next
|
|
|
|
# monitor in that direction.
|
|
|
|
#
|
|
|
|
# Makes switching nodes more intuitive.
|
|
|
|
#
|
|
|
|
# Usage: bspc-focus [-m] (west|south|north|east)
|
|
|
|
# Example:
|
|
|
|
# + bspc-focus south
|
|
|
|
# + bspc-focus -m west
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
leap=
|
|
|
|
if [[ $1 == -m ]]; then
|
|
|
|
leap=1; shift
|
|
|
|
fi
|
|
|
|
dir=$1
|
2019-12-03 20:45:57 -08:00
|
|
|
opposite=
|
2017-12-05 22:39:10 -08:00
|
|
|
|
2019-12-03 20:45:57 -08:00
|
|
|
case $dir in
|
|
|
|
west) opposite=east ;;
|
|
|
|
east) opposite=west ;;
|
|
|
|
north) opposite=north ;;
|
|
|
|
south) opposite=south ;;
|
2017-12-05 22:39:10 -08:00
|
|
|
*) >&2 echo "Not a valid direction: $dir"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
2017-12-31 22:33:49 -08:00
|
|
|
if [[ -n $leap ]]; then
|
2017-12-05 22:39:10 -08:00
|
|
|
# jump to monitor in direction
|
|
|
|
bspc monitor -f "$dir"
|
|
|
|
else
|
|
|
|
# jump to window in direction (unless at edge of last monitor)
|
|
|
|
if ! bspc node -f "$dir.local"; then
|
|
|
|
if [[ $(bspc query -M -m "$dir") ]]; then
|
|
|
|
bspc monitor -f "$dir"
|
2019-12-03 20:45:57 -08:00
|
|
|
# Ensure we start at the edge of the window we arrived from
|
|
|
|
while bspc node -f "$opposite.local"; do :; done
|
2017-12-05 22:39:10 -08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|