Jorisvandijk.com

Living on Linux

A few cool SXHKD keybindings

I recently discovered the awesomeness that is SXHKD, the Simple X Hot Key Daemon. I use it in combination with the i3 window manager, which means that I don't have to use the ugly way i3 does keybindings anymore, but can use the clean way SXHKD does it. Another big pro is that you can create some really neat keybindings for i3 with SXHKD. One of the coolest things I've found is the ability to merge several keybindings into one.

The following code blocks feature indentation. This is required for SXHKD to function! The first line is the keybinding and the following lines are the action that will be taken.

Moving and moving around

Moving to a workspace [super + workspace number], or moving the currently selected application to that workspace [super + shift + workspace number].

super + {_,shift + }{1-9}
i3-msg {_,move container to }workspace number {1-9}

Launching and switching

Open an application, Gimp in this case, [super + g] or launch it if it is not running by using the SwitchLaunch script I wrote. Or move the currently selected application to the workspace Gimp is on [super + shift + g] from another workspace and then focus (show/move away from the workspace you were on, to the) the Gimp workspace.

super + {_,shift + } g
{bin/SwitchLaunch gimp, i3-msg move container to workspace \
Gimp; i3-msg workspace Gimp}

Power menu

Pressing [super + Delete] will activate a keychord. This means that after pressing this key combination, you have to press another key after letting go of the key combination in order for it to do a specific action. In this case I use this keybinding to trigger my Power menu. Following the above mentioned keybinding, you can either lock the screen [1], log out [2], reboot [3] or power down the machine [4].

So for example, to log out you'd press [super + Delete], release these keys, then press [2].

super + Delete; {1,2,3,4}
{dm-tool switch-to-greeter, i3-msg exit, reboot, systemctl poweroff -i, \
mode "default"}

Screen capturing

Take a screenshot using my screenshot script [PrintScreen], or taking a screenshot of a selection of the screen [Shift + PrintScreen].

{_,shift + } Print
{bin/ScreenShot, scrot ~/Pictures/ss/%d-%m-%Y-%T.png \
-s -e 'xclip -selection c -t image/png < $f'}

Controlling playback

In order to control playback from playerctl compatible software, like Spotify, you can use the following binding. You can toggle play-pause [super + Down], go to the next song [super + Right] or listen to the previous one [super + Left].

super + {Down, Left, Right}
playerctl {play-pause, previous, next}

Controlling volume

And obviously it'd be nice to use my default media keys to control things like backlight or volume. This one is an example of how to use volume up [VolumeUpKey] and volume down [VolumeDownKey] to do just that.

{XF86AudioLowerVolume, XF86AudioRaiseVolume}
pactl set-sink-volume @DEFAULT_SINK@ {-,+}5%

I use many other keybindings in my SXHKD file and in the future I might add more or change the ones I have to improve upon them. If you're interested in seeing an up to date version of this file, head over to my dotfiles repository.