## ~/.config/sxhkd/default: wm-independent keybinds

#include <theme.h>
#include <colors/nightdrive.h>

## essential
# terminate X session
ctrl + shift + q
	sfx-synth prompt & \
	printf 'āœ“\nāœ˜' | dmenu -f \
		-p 'Terminate X session?' -sb str(COLOR6) -sf str(COLOR0) \
		| fgrep -q 'āœ“' && pkill -t "tty$XDG_VTNR" X &
# launcher
super + p
	sfx-synth btn & \
	dmenu_path | dmenu -f | sh &
# terminal
super + Return
	urxvtc || urxvt
# file manager
{super + e,XF86Explorer}
	sfx-synth btn & \
	pcmanfm
# take screenshot
{_,shift +} super + Print
	sfx-synth btn & \
	{scrot,scrot -fs}; \
	notify-send -t 1 'Screenshot saved.'
# ssh-agent
super + BackSpace
	sfx-synth attn & \
	! ssh-add -l && ssh-add || ssh-add -D; \
	ssh-add -l | notify-send -t 2
# task manager/syslog
ctrl + alt + {Delete,Insert}
	sfx-synth btn & \
	visual {htop,watch -c -n 0.1 'dmesg -e -Lalways | tac'}

## function keys
# F1: power/reboot
# F2: suspend/hibernate+poweroff
{_,shift +} super + F{1,2}
	sfx-synth btn & \
	systemctl {poweroff,reboot,suspend,hibernate}

# F3: display off/hibernate+reboot
{_,shift +} super + F3
	sfx-synth btn & \
	ssh-add -D && {sleep 1; xset dpms force off, systemctl hybrid-sleep}

# F4: calculator/networking
# use x48 netbook view on small displays
{_,shift +} {super + F4,XF86Calculator}
	sfx-synth btn & \
	{x48-resize,visual bash -ic nmtui}

# F5: toggle displays/configure displays
{_,shift +} {super + F5,XF86Display}
	sfx-synth btn & \
	{xrandr-cycle | tail -n +2 | head -n 1 | notify-send,arandr}

# F6, F7: adjust brightness (shift + to jump to both extremes)
#define BRIGHTNESS_CMD 	\
	sfx-synth btn & \
	xbacklight -{dec 10,set 1,inc 10,set 100}; \
	xbacklight -get | sed -E -e 's/0+$//' -e 's/\.$//' | \
		xargs -I '*' notify-send -t 0.3 'Backlight: *%'

{_,shift +} super + F{6,7}
	BRIGHTNESS_CMD
{_,shift +} XF86MonBrightness{Down,Up}
	BRIGHTNESS_CMD

# F8: mute, configure audio
{super + F8,XF86AudioMute}
	sfx-synth btn & \
	pactl set-sink-mute '@DEFAULT_SINK@' toggle

shift + {super + F8,XF86AudioMute}
	sfx-synth btn & \
	pavucontrol

# F9, F10: adjust volume, (shift + was purposefully excluded here)
#define VOLUME_CMD \
	sfx-synth btn & \
	pactl set-sink-volume '@DEFAULT_SINK@' {-5%,+5%}; \
	amixer sget Master | egrep -e '[0-9]+%' \
		| egrep -o '\[.+\]' | head -n 1 | xargs -I '*' notify-send -t 0.4 'šŸ”‰ *' &

super + F{9,10}
	VOLUME_CMD
XF86Audio{LowerVolume,RaiseVolume}
	VOLUME_CMD

# F11: randomize wallpaper
super + F11
	sfx-synth btn & \
	xwin-decor

## optional keyboard hotkeys
XF86{WWW,HomePage}
	chromium
XF86Eject
	eject

## reserved for future use
# F12~F24
# Insert
# SysRq
# Scroll_Lock
# Pause
# XF86Tools (probably a music player)
# X86FAudio{Prev,Next,Play,Stop}
# XF86Launch1,5,6 (???)