Add hardware media key bindings
8e37882ffa996e46ac4ad11bf491258c267a95d1
1 parent
9f249ed5
config.def.h
+38 -0
| 139 | 139 | static const char *termcmd[] = { "foot", nullptr }; |
|
| 140 | 140 | /* Application launcher opened by MOD+P. */ |
|
| 141 | 141 | static const char *menucmd[] = { "fuzzel", nullptr }; |
|
| 142 | 142 | /* Session locker started by MOD+X. */ |
|
| 143 | 143 | static const char *lockcmd[] = { "swaylock", "-f", "-c", "000000", nullptr }; |
|
| 144 | + | /* Raise, lower, or mute the default PipeWire audio sink. */ |
|
| 145 | + | static const char *volumeupcmd[] = { |
|
| 146 | + | "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%+", nullptr |
|
| 147 | + | }; |
|
| 148 | + | static const char *volumedowncmd[] = { |
|
| 149 | + | "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%-", nullptr |
|
| 150 | + | }; |
|
| 151 | + | static const char *volumemutecmd[] = { |
|
| 152 | + | "wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle", nullptr |
|
| 153 | + | }; |
|
| 154 | + | /* Adjust the display and keyboard backlight brightness. */ |
|
| 155 | + | static const char *brightnessupcmd[] = { |
|
| 156 | + | "brightnessctl", "set", "5%+", nullptr |
|
| 157 | + | }; |
|
| 158 | + | static const char *brightnessdowncmd[] = { |
|
| 159 | + | "brightnessctl", "set", "5%-", nullptr |
|
| 160 | + | }; |
|
| 161 | + | static const char *keyboardbrightnessupcmd[] = { |
|
| 162 | + | "brightnessctl", "--device", "*::kbd_backlight", "set", "5%+", nullptr |
|
| 163 | + | }; |
|
| 164 | + | static const char *keyboardbrightnessdowncmd[] = { |
|
| 165 | + | "brightnessctl", "--device", "*::kbd_backlight", "set", "5%-", nullptr |
|
| 166 | + | }; |
|
| 167 | + | /* Control media players through MPRIS. */ |
|
| 168 | + | static const char *mediapreviouscmd[] = { "playerctl", "previous", nullptr }; |
|
| 169 | + | static const char *medianextcmd[] = { "playerctl", "next", nullptr }; |
|
| 170 | + | static const char *mediaplaypausecmd[] = { "playerctl", "play-pause", nullptr }; |
|
| 144 | 171 | ||
| 145 | 172 | /* Run these commands once at startup. A nullptr separates commands, and a |
|
| 146 | 173 | * second nullptr ends the list. Environment variables are expanded without |
|
| 147 | 174 | * shell word splitting. */ |
|
| 148 | 175 | static const char *const autostart[] = { |
| 216 | 243 | { MOD, XKB_KEY_9, view, { .i = 8 } }, |
|
| 217 | 244 | { MOD | SHIFT, XKB_KEY_parenleft, tag, { .i = 8 } }, |
|
| 218 | 245 | { MOD, XKB_KEY_0, view, { .i = 9 } }, |
|
| 219 | 246 | { MOD | SHIFT, XKB_KEY_parenright, tag, { .i = 9 } }, |
|
| 220 | 247 | { MOD | SHIFT, XKB_KEY_q, quit, {} }, |
|
| 248 | + | /* Hardware keys control audio, backlights, and media without a modifier. */ |
|
| 249 | + | { 0, XKB_KEY_XF86AudioRaiseVolume, spawn, { .v = volumeupcmd } }, |
|
| 250 | + | { 0, XKB_KEY_XF86AudioLowerVolume, spawn, { .v = volumedowncmd } }, |
|
| 251 | + | { 0, XKB_KEY_XF86AudioMute, spawn, { .v = volumemutecmd } }, |
|
| 252 | + | { 0, XKB_KEY_XF86MonBrightnessUp, spawn, { .v = brightnessupcmd } }, |
|
| 253 | + | { 0, XKB_KEY_XF86MonBrightnessDown, spawn, { .v = brightnessdowncmd } }, |
|
| 254 | + | { 0, XKB_KEY_XF86KbdBrightnessUp, spawn, { .v = keyboardbrightnessupcmd } }, |
|
| 255 | + | { 0, XKB_KEY_XF86KbdBrightnessDown, spawn, { .v = keyboardbrightnessdowncmd } }, |
|
| 256 | + | { 0, XKB_KEY_XF86AudioPrev, spawn, { .v = mediapreviouscmd } }, |
|
| 257 | + | { 0, XKB_KEY_XF86AudioNext, spawn, { .v = medianextcmd } }, |
|
| 258 | + | { 0, XKB_KEY_XF86AudioPlay, spawn, { .v = mediaplaypausecmd } }, |
|
| 221 | 259 | ||
| 222 | 260 | /* Preserve the traditional Ctrl+Alt+Backspace shortcut for quitting. */ |
|
| 223 | 261 | { CTRL | ALT, XKB_KEY_Terminate_Server, quit, {} }, |
|
| 224 | 262 | /* Ctrl+Alt+Fn switches to another virtual terminal. */ |
|
| 225 | 263 | { CTRL | ALT, XKB_KEY_XF86Switch_VT_1, change_vt, { .u = 1 } }, |