# -*- conf -*-


##--- Control ---##


# Restart bspwm
super + shift + r
	bspc wm -r && notify-send -t 1000 "bspwm reloaded."


##--- Node ---##


# Close and kill focused node
super + {_,shift} + q
	bspc node -{c,k}

#-- State/flags --#

# Toggle fullscreen mode
super + f
	bspc node -t \~fullscreen

# Toggle tiled/floating
super + space
	bspc query -N -n focused.tiled && \
	bspc node -t floating || bspc node -t tiled -g sticky=off

# Sticky floating node
super + shift + f
	bspc node -t floating -g sticky=on; $HOME/.local/bin/wm/hover.sh

# Set node flags
super + ctrl + {s,p,semicolon}
	bspc node -g {sticky,private,locked}

#-- Focus --#

# Focus node in direction
super + {_,shift} + {h,j,k,l}
	bspc node -{f,s} {west,south,north,east}.local
super + {_,shift} + {Left,Down,Up,Right}
	bspc node -{f,s} {west,south,north,east}.local

# Focus the node for the given path jump
super + {p,b,comma,period}
	bspc node -f @{parent,brother,first,second}.local

# Focus previous/next node
super + {_,shift} + Tab
	bspc node -f {next,prev}.local

# Focus previous/next monitor
super + bracket{left,right}
	bspc monitor -f {prev,next}

#-- Move --#

# Move node to previous/next/last desktop
super + shift + {minus,equal,grave}
	bspc node -d {prev.local,next.local,last}

# Move node to previous/next monitor
super + shift + bracket{left,right}
	bspc node -m {prev,next} --follow

# Swap focused and biggest node
super + g
	bspc node -s biggest.local

# Send focused node to the latest preselect node
super + y
	bspc node -n newest.!automatic.local

# Move floating window
ctrl + alt + {h,j,k,l}
	bspc node -v {-30 0, 0 30, 0 -30, 30 0}
ctrl + alt + {Left,Down,Up,Right}
	bspc node -v {-30 0, 0 30, 0 -30, 30 0}

# Flip the tree from the current nodes parent
super + alt + {comma,period}
  bspc node @parent -F {vertical,vertical}
super + alt + 6
  bspc node @parent -F horizontal

#-- Resize --#

# Expand node by moving its side outward
super + alt + {h,j,k,l}
	bspc node -z {left -30 0,bottom 0 30,top 0 -30,right 30 0}
super + alt + {Left,Down,Up,Right}
	bspc node -z {left -30 0,bottom 0 30,top 0 -30,right 30 0}

# Contract node by moving its side inward
super + alt + ctrl + {h,j,k,l}
	bspc node -z {right -30 0,top 0 30,bottom 0 -30,left 30 0}
super + alt + ctrl + {Left,Down,Up,Right}
	bspc node -z {right -30 0,top 0 30,bottom 0 -30,left 30 0}

#-- Preselect node --#

# Preselect direction
super + ctrl + {h,j,k,l}
	bspc node -p {west,south,north,east}
super + ctrl + {Left,Down,Up,Right}
	bspc node -p {west,south,north,east}

# Preselect ratio
super + ctrl + {1-9}
	bspc node -o 0.{1-9}

# Cancel preselection in focused node
super + ctrl + space
	bspc node -p cancel


##--- Desktop ---##


# Toggle tiled/monocle layout
super + z
	bspc desktop -l next

# Focus/send node to desktop
super + {_,shift} + {1-9,0}
	bspc {desktop -f,node -d} '^{1-9,10}'

# Focus the previous/next desktop on current monitor
super + {minus,equal}
	bspc desktop -f {prev,next}.local

# Focus last desktop
super + grave
	bspc desktop -f last