#
# wm independent hotkeys
#

# terminal emulator
{alt, super} + Return
	alacritty

# program launcher
{alt, super} + @space
	rofi -show combi -dpi $DPI

# make sxhkd reload its configuration files:
{alt, super} + Escape
	pkill -USR1 -x sxhkd

# screen capture
alt + ctrl + shift + {3,4}
	maim -u { ~/Pictures/screenshot.png ,-s | xclip -selection clipboard -t image/png }

#
# bspwm hotkeys
#

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

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

# alternate between the tiled and monocle layout
alt + m
	bspc desktop -l next

# send the newest marked node to the newest preselected node
alt + y
	bspc node newest.marked.local -n newest.!automatic.local

# swap the current node and the biggest node
alt + g
	bspc node -s biggest

#
# state/flags
#

# set the window state
alt + {t,shift + t, f,shift + f}
	bspc node -t {tiled,pseudo_tiled,floating,fullscreen}

alt + s
	bspc node -g sticky

alt + shift + p
	bspc node --state \~pseudo_tiled

#
# focus/swap
#

# focus the node in the given direction
alt + {_,shift + }{h,j,k,l}
	bspc node -{f,s} {west,south,north,east}

# focus the node for the given path jump
# alt + {p,b,comma,period}
# 	bspc node -f @{parent,brother,first,second}

# focus the next/previous node in the current desktop
alt + {_,shift + }c
	bspc node -f {next,prev}.local

# focus the next/previous desktop in the current monitor
alt + bracket{left,right}
	bspc desktop -f {prev,next}.local

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

# focus the older or newer node in the focus history
alt + {o,i}
	bspc wm -h off; \
	bspc node {older,newer} -f; \
	bspc wm -h on

# focus or send to the given desktop
alt + {_,shift + }{1-9,0}
	bspc {desktop -f,node -d} '^{1-9,10}'

#
# preselect
#

# preselect the direction
alt + ctrl + {h,j,k,l}
	bspc node -p {west,south,north,east}

# preselect the ratio
alt + ctrl + {1-9}
	bspc node -o 0.{1-9}

# cancel the preselection for the focused node
alt + ctrl + space
	bspc node -p cancel

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

#
# move/resize
#

# expand a window by moving one of its side outward
alt + super + {h,j,k,l}
	bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}

# contract a window by moving one of its side inward
alt + super + shift + {h,j,k,l}
	bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}

# move a floating window
# alt + {Left,Down,Up,Right}
# 	bspc node -v {-20 0,0 20,0 -20,20 0}

# toggle pip mode
alt + p
	bspc node -g sticky; \
	bspc node --state \~floating; \
	xdotool getactivewindow windowsize $(expr 620 \* $SCALE) $(expr 349 \* $SCALE) windowmove $(expr $XSIZE - $(expr 620 + 45) \* $SCALE) $(expr $YSIZE - $(expr 349 + 30) \* $SCALE)


XF86AudioMute
 pactl set-sink-mute @DEFAULT_SINK@ toggle

XF86AudioLowerVolume
 pactl set-sink-volume @DEFAULT_SINK@ -5%

XF86AudioRaiseVolume
 pactl set-sink-volume @DEFAULT_SINK@ +5%

XF86MonBrightnessUp
 xbacklight -ctrl $BACKLIGHT -inc 5

XF86MonBrightnessDown
 xbacklight -ctrl $BACKLIGHT -dec 5

XF86KbdBrightnessUp
 xbacklight -ctrl smc::kbd_backlight -inc 10

XF86KbdBrightnessDown
 xbacklight -ctrl smc::kbd_backlight -dec 10
