#
# wm independent hotkeys
#

# Open terminal
super + Return
	xfce4-terminal

# Open floating terminal
super + shift + Return
	bsp-float xfce4-terminal

# launch program (drun)
super + @space
	rofi -show drun -show-icons

# launch program (standard run)
super + shift + @space
	rofi -show run

# make sxhkd reload its configuration files:
super + Escape
	pkill -USR1 -x sxhkd && notify-send 'Key daemon reloaded'

super + alt + Menu
	le-keyboard && notify-send 'Remapped Keyboard'
	
# Start a qutebrowser search
super + o
	qutesearch

# Preselect below and start a qutebrowser search
super + p
	bspc node -p south -o 0.01 \
		&& qutesearch \
			|| bspc node -p cancel

# Grab color
Print
	grabc | xclip -sel clipboard

# Show keybinds
super + slash
	sxhkd-help

# Show clipmenu
super + v
	xfce4-popup-clipman
	
# Exit session
super + q
	xflock4

# Lock screen
super + shift + q
	xfce4-session-logout

# Open task manager
super + t
	# Arguable how valuable this is tbh
	bsp-float xfce4-taskmanager

# Screenshot region
XF86Launch5
	flameshot gui
	# xfce4-screenshooter -r

# Manage audio profiles[57362;10u]
super + shift + Pause
	le-audio

# Cycle audio profile on default sink
super + Pause
	le-audio -afc

#
# bspwm hotkeys
#

# quit/restart bspwm
super + shift + {q,r}
	bspc {quit,wm -r}

# close and kill
super + {_,shift + }w
	bspc node -{c,k}

# superernate between the tiled and monocle layout
super + m
	bspc desktop -l next

# swap the current node and the biggest window
super + g
	bspc node -s biggest.window

#
# state/flags
#

# toggle window state
super + c
	bspc node 'focused.!tiled' -t tiled || bspc node 'focused.!floating' -t floating
# bspc node 'focused.!pseudo_tiled' -t pseudo_tiled

# toggle window fullscreen
super + f
	bspc node 'focused.!tiled' -t tiled || bspc node 'focused.!fullscreen' -t fullscreen


# set the node flags
super + ctrl + {m,x,y,z}
	bspc node -g {marked,locked,sticky,private}

#
# focus/swap
#

# Focus the node in the given direction
super + {h,j,k,l,Left,Down,Up,Right}
	bspc node -{f} {west,south,north,east,west,south,north,east}

# Rotate focus clockwise/counterclockwise
super + {d,a}
    bspc node -f {next,prev}.local.window

# focus the last node/desktop
super + {grave,Tab}
	bspc {node,desktop} -f last

# focus or send to the given desktop
super + {_,shift + }{1-6}
	bspc {desktop -f,node -d} '^{1-6}'

#
# preselect
#

# preselect the direction
super + ctrl + shift {h,j,k,l,Left,Down,Up,Right}
	bspc node -p {west,south,north,east,west,south,north,east}
	
# cancel the preselection for the focused node
super + ctrl + space
	bspc node -p cancel

# cancel the preselection for the focused desktop
super + ctrl + shift + space
	bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel

# swap current window with preselection
super + s
	bspc node -n last.\!automatic -t tiled

#
# move/resize
#

# Resize a window by moving one of its side outward/inward
super + s ; {h,j,k,l,Left,Down,Up,Right}
	STEP=20; SELECTION={1,2,3,4,1,2,3,4}; \
	bspc node -z $(echo "left -$STEP 0,bottom 0 $STEP,top 0 -$STEP,right $STEP 0" | cut -d',' -f$SELECTION) || \
	bspc node -z $(echo "right -$STEP 0,top 0 $STEP,bottom 0 -$STEP,left $STEP 0" | cut -d',' -f$SELECTION)

# move a floating window
super + {h,j,k,l}
	bspc node -v {-30 0,0 20,0 -30,20 0}

# move a window
super + shift + {h,j,k,l,Left,Down,Up,Right}
	bsp-smove {west,south,north,east,west,south,north,east}

# minimize current window, move down
super + {z,bracketleft}
	bspc node -f 'focused.tiled' \
		&& bspc node -f north; \
	bspc node -z bottom 0 9999

# minimize current window, move up
super + {x,bracketright}
	bspc node -f 'focused.tiled' \
		&& bspc node -f south; \
	bspc node -z top 0 -9999
		
super + backslash
	bspc node -e

#
# Program launching binds
#

super + 8
	vesktop

super + 9
	bitwarden

super + 0
	kitty -e micro

#
# Media
#

# Play/pause track
XF86AudioPlay
    playerctl play-pause

# Play/pause track
Pause
    playerctl play-pause

# Previus track
XF86AudioNext
    playerctl next
 
# Previous track
XF86AudioPrev
    playerctl previous
 
# Stop track
XF86AudioStop
    playerctl stop
