38 lines
		
	
	
		
			772 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			772 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/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
 | 
						|
 | 
						|
case $dir in west|south|north|east) ;;
 | 
						|
    *) >&2 echo "Not a valid direction: $dir"
 | 
						|
        exit 1
 | 
						|
esac
 | 
						|
 | 
						|
if [[ -n $leap ]]; then
 | 
						|
    # 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"
 | 
						|
        fi
 | 
						|
    fi
 | 
						|
fi
 |