···
1
+
# Converted with regex from hyprland config
2
+
# search: ^(\s*)(bind[rwelm]*) = (|\w+), (|\$?\w+), (.+)$ /gm
3
+
# replace: $1$2."$3, $4" = "$5";
5
+
{ config, pkgs, lib, ... }: {
6
+
# <https://wiki.hyprland.org/Configuring/Dispatchers/>
7
+
wayland.windowManager.hyprland.keyBinds = let
8
+
MOUSE_LMB = "mouse:272";
9
+
MOUSE_RMB = "mouse:273";
10
+
# MOUSE_MMB = "mouse:274";
11
+
MOUSE_EX1 = "mouse:275";
12
+
MOUSE_EX2 = "mouse:276";
15
+
screenshotWindow = pkgs.patchShellScript ./scripts/screenshot.sh {
16
+
runtimeInputs = with pkgs; [
21
+
config.wayland.windowManager.hyprland.package
24
+
playerctl = lib.getExe pkgs.playerctl;
25
+
slight = lib.getExe pkgs.slight;
26
+
osdFunc = lib.getExe config.utilities.osd-functions.package;
27
+
airplaneMode = "sudo /run/current-system/sw/bin/airplane-mode";
29
+
pkgs.patchShellScript ./scripts/toggle-group-or-lock.sh {
30
+
runtimeInputs = with pkgs; [
32
+
config.wayland.windowManager.hyprland.package
37
+
# Collections of keybinds common across multiple submaps are collected into
38
+
# groups, which can be merged together granularly.
40
+
# Exit the submap and restore normal binds.
42
+
bind.", escape" = "submap, reset";
43
+
bind."CTRL, C" = "submap, reset";
48
+
# Launch the program with a shortcut.
49
+
bind."SUPER, E" = "exec, dolphin";
50
+
bind."SUPER, Enter" = "exec, alacritty";
53
+
# Kill the active window.
54
+
killWindow = { bind."SUPER, Q" = "killactive,"; };
56
+
# Either window focus or window movement.
57
+
moveFocusOrWindow = with groups;
58
+
lib.mkMerge [ moveFocus moveWindow mouseMoveWindow ];
60
+
# Focus on another window, in the specified direction.
62
+
bind."SUPER, left" = "movefocus, l";
63
+
bind."SUPER, right" = "movefocus, r";
64
+
bind."SUPER, up" = "movefocus, u";
65
+
bind."SUPER, down" = "movefocus, d";
68
+
# Swap the active window with another, in the specified direction.
70
+
bind."SUPER_SHIFT, left" = "movewindow, l";
71
+
bind."SUPER_SHIFT, right" = "movewindow, r";
72
+
bind."SUPER_SHIFT, up" = "movewindow, u";
73
+
bind."SUPER_SHIFT, down" = "movewindow, d";
76
+
# Translate the dragged window by mouse movement.
78
+
bindm."SUPER, ${MOUSE_LMB}" = "movewindow";
79
+
bindm.", ${MOUSE_EX2}" = "movewindow";
82
+
# Toggle between vertical and horizontal split for
83
+
# the active window and an adjacent one.
84
+
toggleSplit = { bind."SUPER, tab" = "togglesplit,"; };
86
+
# Resize a window with the mouse.
87
+
mouseResizeWindow = {
88
+
bindm."SUPER, ${MOUSE_RMB}" = "resizewindow";
89
+
bindm.", ${MOUSE_EX1}" = "resizewindow";
92
+
# Switch to the next/previous tab in the active group.
93
+
changeGroupActive = {
94
+
bind."ALT, tab" = "changegroupactive, f";
95
+
bind."ALT, grave" = "changegroupactive, b";
98
+
# Switch to another workspace.
99
+
switchWorkspace = with groups;
100
+
lib.mkMerge [ switchWorkspaceAbsolute switchWorkspaceRelative ];
102
+
# Switch to a workspace by absolute identifier.
103
+
switchWorkspaceAbsolute = {
104
+
# Switch to a primary workspace by index.
105
+
bind."SUPER, 1" = "workspace, 1";
106
+
bind."SUPER, 2" = "workspace, 2";
107
+
bind."SUPER, 3" = "workspace, 3";
108
+
bind."SUPER, 4" = "workspace, 4";
109
+
bind."SUPER, 5" = "workspace, 5";
110
+
bind."SUPER, 6" = "workspace, 6";
111
+
bind."SUPER, 7" = "workspace, 7";
112
+
bind."SUPER, 8" = "workspace, 8";
113
+
bind."SUPER, 9" = "workspace, 9";
114
+
bind."SUPER, 0" = "workspace, 10";
116
+
# Switch to an alternate workspace by index.
117
+
bind."SUPER_ALT, 1" = "workspace, 11";
118
+
bind."SUPER_ALT, 2" = "workspace, 12";
119
+
bind."SUPER_ALT, 3" = "workspace, 13";
120
+
bind."SUPER_ALT, 4" = "workspace, 14";
121
+
bind."SUPER_ALT, 5" = "workspace, 15";
122
+
bind."SUPER_ALT, 6" = "workspace, 16";
123
+
bind."SUPER_ALT, 7" = "workspace, 17";
124
+
bind."SUPER_ALT, 8" = "workspace, 18";
125
+
bind."SUPER_ALT, 9" = "workspace, 19";
126
+
bind."SUPER_ALT, 0" = "workspace, 20";
128
+
# TODO Bind the special workspace to `XF86Favorites`.
129
+
# TODO Create a bind for "insert after current workspace".
132
+
# Switch to workspaces relative to the current one.
133
+
switchWorkspaceRelative = {
134
+
# Switch to the next/previous used workspace with page keys.
135
+
bind."SUPER, page_down" = "workspace, m+1";
136
+
bind."SUPER, page_up" = "workspace, m-1";
138
+
# Switch to the next/previous used workspace
139
+
# with the right and left square brackets,
140
+
# while holding super and shift.
141
+
bind."SUPER, bracketright " = "workspace, m+1";
142
+
bind."SUPER, bracketleft" = "workspace, m-1";
144
+
# Switch to the next/previous used workspace with the mouse wheel.
145
+
bind."SUPER, mouse_up" = "workspace, m+1";
146
+
bind."SUPER, mouse_down" = "workspace, m-1";
149
+
# Send a window to another workspace.
150
+
sendWindow = with groups;
151
+
lib.mkMerge [ sendWindowAbsolute sendWindowRelative ];
153
+
# Send a window to a workspace by absolute identifier.
154
+
sendWindowAbsolute = {
155
+
# Move the active window or group to a primary workspace by index.
156
+
bind."SUPER_SHIFT, 1" = "movetoworkspacesilent, 1";
157
+
bind."SUPER_SHIFT, 2" = "movetoworkspacesilent, 2";
158
+
bind."SUPER_SHIFT, 3" = "movetoworkspacesilent, 3";
159
+
bind."SUPER_SHIFT, 4" = "movetoworkspacesilent, 4";
160
+
bind."SUPER_SHIFT, 5" = "movetoworkspacesilent, 5";
161
+
bind."SUPER_SHIFT, 6" = "movetoworkspacesilent, 6";
162
+
bind."SUPER_SHIFT, 7" = "movetoworkspacesilent, 7";
163
+
bind."SUPER_SHIFT, 8" = "movetoworkspacesilent, 8";
164
+
bind."SUPER_SHIFT, 9" = "movetoworkspacesilent, 9";
165
+
bind."SUPER_SHIFT, 0" = "movetoworkspacesilent, 10";
167
+
# Move the active window or group to an alternate workspace by index.
168
+
bind."SUPER_ALT_SHIFT, 1" = "movetoworkspacesilent, 11";
169
+
bind."SUPER_ALT_SHIFT, 2" = "movetoworkspacesilent, 12";
170
+
bind."SUPER_ALT_SHIFT, 3" = "movetoworkspacesilent, 13";
171
+
bind."SUPER_ALT_SHIFT, 4" = "movetoworkspacesilent, 14";
172
+
bind."SUPER_ALT_SHIFT, 5" = "movetoworkspacesilent, 15";
173
+
bind."SUPER_ALT_SHIFT, 6" = "movetoworkspacesilent, 16";
174
+
bind."SUPER_ALT_SHIFT, 7" = "movetoworkspacesilent, 17";
175
+
bind."SUPER_ALT_SHIFT, 8" = "movetoworkspacesilent, 18";
176
+
bind."SUPER_ALT_SHIFT, 9" = "movetoworkspacesilent, 19";
177
+
bind."SUPER_ALT_SHIFT, 0" = "movetoworkspacesilent, 20";
180
+
# Send windows to other workspaces, relative to the current one.
181
+
sendWindowRelative = {
182
+
# Move the active window or group to the next/previous
183
+
# workspace with page keys, while holding super and shift.
184
+
bind."SUPER_SHIFT, page_down" = "movetoworkspace, r+1";
185
+
bind."SUPER_SHIFT, page_up" = "movetoworkspace, r-1";
187
+
# Move the active window or group to the next/previous
188
+
# workspace with the right and left square brackets,
189
+
# while holding super and shift.
190
+
bind."SUPER_SHIFT, bracketright" = "movetoworkspace, r+1";
191
+
bind."SUPER_SHIFT, bracketleft" = "movetoworkspace, r-1";
193
+
# Move the active window or group to the next/previous
194
+
# workspace with the mouse wheel while holding super and shift.
195
+
bind."SUPER_SHIFT, mouse_up" = "movetoworkspace, r+1";
196
+
bind."SUPER_SHIFT, mouse_down" = "movetoworkspace, r-1";
200
+
### ACTIVE WINDOW ACTIONS ###
203
+
# Toggle full-screen for the active window.
204
+
bind."SUPER_SHIFT, F" = "fullscreen, 0";
206
+
# Float/unfloat the active window.
207
+
bind."SUPER, F" = "togglefloating,";
209
+
### MISCELLANEOUS ###
211
+
# Lock the session immediately.
212
+
bind."SUPER, l" = "exec, loginctl lock-session";
214
+
# Kill the window manager.
215
+
bind."SUPER_SHIFT, M" = "exit,";
217
+
# Forcefully kill a program after selecting its window with the mouse.
218
+
bind."SUPER_SHIFT, Q" = "exec, hyprctl kill";
220
+
# Screenshot the currently focused window and copy to clipboard.
221
+
bind."SUPER, print" = "exec, ${exec.screenshotWindow}";
223
+
# Select a region and take a screenshot, saving to the clipboard.
224
+
bind."SUPER_SHIFT, print" = "exec, prtsc -c -m r -D -b 00000066";
226
+
# Bypass all binds for the window manager and pass key combinations
227
+
# directly to the active window.
228
+
bind."SUPER_SHIFT, K" = "submap, passthru";
229
+
submap.passthru = { bind."SUPER_SHIFT, K" = "submap, reset"; };
231
+
### PROGRAM LAUNCHING ###
232
+
groups.launchPrograms
234
+
# Open Rofi to launch a program.
235
+
bind."SUPER, Space" = "exec, rofi -show drun -show-icons";
236
+
# Open Rofi to run a command.
237
+
bind."SUPER, R" = "exec, rofi -show run";
239
+
### FUNCTION KEYS ###
241
+
# The names of these keys can be found at:
242
+
# <https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h>
244
+
bindl."SHIFT, XF86WLAN" = "exec, ${exec.airplaneMode}";
246
+
# Mute/unmute the active audio output.
247
+
bindl.", XF86AudioMute" = "exec, ${exec.osdFunc} output mute";
249
+
# Raise and lower the volume of the active audio output.
250
+
bindel.", XF86AudioRaiseVolume" = "exec, ${exec.osdFunc} output +0.05";
251
+
bindel.", XF86AudioLowerVolume" = "exec, ${exec.osdFunc} output -0.05";
253
+
# Mute the active microphone or audio source.
254
+
bindl.", XF86AudioMicMute" = "exec, ${exec.osdFunc} input mute";
256
+
# Raise and lower display brightness.
257
+
bindel.", XF86MonBrightnessUp" = "exec, ${exec.slight} inc 10 -t 300ms";
258
+
bindel.", XF86MonBrightnessDown" = "exec, ${exec.slight} dec 10 -t 300ms";
260
+
# Regular media control keys, if your laptop or bluetooth device has them.
261
+
bindl.", XF86AudioPlay" = "exec, ${exec.playerctl} play-pause";
262
+
bindl.", XF86AudioPrev" = "exec, ${exec.playerctl} previous";
263
+
bindl.", XF86AudioNext" = "exec, ${exec.playerctl} next";
265
+
# Poor-man's media player control keys.
266
+
bindl."SUPER, slash" = "exec, ${exec.playerctl} play-pause";
267
+
bindl."SUPER, comma" = "exec, ${exec.playerctl} previous";
268
+
bindl."SUPER, period" = "exec, ${exec.playerctl} next";
270
+
### WINDOW FOCUS & MOVEMENT ###
271
+
groups.moveFocusOrWindow
272
+
### WINDOW RESIZING ###
274
+
groups.mouseResizeWindow
276
+
### WORKSPACE SWITCHING ###
277
+
groups.switchWorkspace
278
+
### WORKSPACE WINDOW MOVEMENT ###