config.def.h 15.7 KiB raw
1
// clang-format off
2
3
/* Short names used to compose modifiers in the key and button tables. */
4
#define MOD   WLR_MODIFIER_LOGO
5
#define SHIFT WLR_MODIFIER_SHIFT
6
#define CTRL  WLR_MODIFIER_CTRL
7
#define ALT   WLR_MODIFIER_ALT
8
9
/* Create this many numbered workspaces. Valid values are 1 through 32. */
10
#define WSCOUNT (10)
11
12
/* Convert an 0xRRGGBBAA color to the floating-point format used by wlroots. */
13
#define RGBA(hex)                                                              \
14
    { ((hex >> 24) & 0xFF) / 255.0f,                                           \
15
      ((hex >> 16) & 0xFF) / 255.0f,                                           \
16
      ((hex >> 8)  & 0xFF) / 255.0f,                                           \
17
       (hex        & 0xFF) / 255.0f }
18
19
/* Focus follows the pointer when enabled. */
20
static const bool         sloppyfocus   = true;
21
/* Borders are measured in physical layout pixels. */
22
static const unsigned int borderwidth   = 1;
23
/* Fill uncovered parts of the desktop with this color. */
24
static const float        rootcolor[]   = RGBA(0x222222ff);
25
/* Draw this color around an unfocused window. */
26
static const float        bordercolor[] = RGBA(0x101010ff);
27
/* Draw this color around the focused window. */
28
static const float        focuscolor[]  = RGBA(0x404040ff);
29
/* Draw this color around a window requesting attention. */
30
static const float        urgentcolor[] = RGBA(0xb03060ff);
31
/* Place this translucent color behind matching layer surfaces. */
32
static const float        dimcolor[]    = RGBA(0x00000080);
33
34
/* This background hides other windows behind transparent fullscreen content,
35
 * as required by the XDG shell protocol. Set its alpha to zero to disable it. */
36
static const float fullscreen_bg[] = {
37
    0.0f, 0.0f, 0.0f, 1.0f
38
};
39
40
/* Report errors only. Use WLR_DEBUG for detailed wlroots diagnostics. */
41
static int log_level = WLR_ERROR;
42
43
/* Window rules are applied in order; later matches override earlier ones.
44
 * Use "*" as the application ID to match every window. Workspace and monitor
45
 * numbers start at zero, and -1 keeps the window's default placement. */
46
static const rule_t rules[] = {
47
    /* application ID         title    workspace  floating  monitor  borderless */
48
    { "org.telegram.desktop", nullptr,  -1, true,        -1,        true },
49
    {},
50
};
51
52
/* Layer rules match panels, launchers, and other desktop surfaces by namespace. */
53
static const layer_rule_t layerrules[] = {
54
    /* namespace  background dim color */
55
    { "launcher", dimcolor },
56
};
57
58
/* Layouts marked true participate in MOD+Space cycling. The max-stack layout
59
 * is selected separately with MOD+F. */
60
static const layout_t layouts[] = {
61
    /* arrangement function  cycle with MOD+Space */
62
    { master_left,        true },
63
    { master_top,         true },
64
    { master_right,       true },
65
    { master_bottom,      true },
66
    { max_stack,          false },
67
};
68
69
/* Display rules match by output name. A nullptr name is the required fallback
70
 * rule. The position (-1, -1) asks wlroots to place the display automatically;
71
 * other negative positions can break XWayland applications. */
72
static const monitor_rule_t monrules[] = {
73
    /* name        scale  rotation/reflection          x    y
74
     * Example for a high-density laptop display:
75
     { "eDP-1",    2,    WL_OUTPUT_TRANSFORM_NORMAL,   -1,  -1 }, */
76
    { nullptr, 1.5, WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
77
    /* Keep at least one fallback rule. */
78
};
79
80
/* XKB keyboard layout shared by physical keyboards. */
81
static const struct xkb_rule_names xkb_rules = {
82
    /* XKB layout name. */
83
    .layout  = "us",
84
    /* Layout variant; altgr-intl provides international characters via AltGr. */
85
    .variant = "altgr-intl",
86
    /* Comma-separated XKB options, or nullptr for none. */
87
    .options = nullptr,
88
};
89
90
/* Repeat a held key this many times per second. */
91
static const int repeat_rate  = 40;
92
/* Wait this many milliseconds before a held key starts repeating. */
93
static const int repeat_delay = 180;
94
95
/* Pointer and touchpad behavior. Unsupported options are ignored per device. */
96
/* Resize a tiled split within this distance from its boundary, in pixels. */
97
static const unsigned tiled_resize_margin = 4;
98
/* Tap the touchpad to produce a click. */
99
static const bool tap_to_click            = true;
100
/* Keep a tapped item grabbed while the finger moves. */
101
static const bool tap_and_drag            = true;
102
/* Keep dragging after the finger is briefly lifted and placed down again. */
103
static const bool drag_lock               = true;
104
/* Reverse the usual scrolling direction when enabled. */
105
static const bool natural_scrolling       = false;
106
/* Ignore touchpad input while typing. */
107
static const bool disable_while_typing    = true;
108
/* Swap the primary and secondary pointer buttons when enabled. */
109
static const bool left_handed             = false;
110
/* Press the left and right buttons together to produce a middle click. */
111
static const bool middle_button_emulation = false;
112
113
/* Scroll with two fingers. Other choices are NO_SCROLL, EDGE, and
114
 * ON_BUTTON_DOWN. */
115
static const enum libinput_config_scroll_method scroll_method =
116
    LIBINPUT_CONFIG_SCROLL_2FG;
117
118
/* Divide the bottom of a clickpad into physical button areas. Other choices
119
 * are NONE and CLICKFINGER. */
120
static const enum libinput_config_click_method click_method =
121
    LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
122
123
/* Keep pointer events enabled. They can instead be disabled always or only
124
 * while an external mouse is connected. */
125
static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
126
127
/* Use adaptive pointer acceleration. FLAT disables the acceleration curve. */
128
static const enum libinput_config_accel_profile accel_profile =
129
    LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
130
/* Pointer speed ranges from -1.0 (slowest) to 1.0 (fastest); 0.0 is neutral. */
131
static const double accel_speed = 0.0;
132
133
/* Map one-, two-, and three-finger taps to left, right, and middle clicks. */
134
static const enum libinput_config_tap_button_map button_map =
135
    LIBINPUT_CONFIG_TAP_MAP_LRM;
136
137
/* Commands are argument vectors and must end with nullptr. */
138
/* Terminal opened by MOD+Shift+Return. */
139
static const char *termcmd[] = { "foot", nullptr };
140
/* Application launcher opened by MOD+P. */
141
static const char *menucmd[] = { "fuzzel", nullptr };
142
/* Session locker started by MOD+X. */
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 };
171
172
/* Run these commands once at startup. A nullptr separates commands, and a
173
 * second nullptr ends the list. Environment variables are expanded without
174
 * shell word splitting. */
175
static const char *const autostart[] = {
176
    "dbus-update-activation-environment", "--systemd",     "WAYLAND_DISPLAY", "XDG_CURRENT_DESKTOP", nullptr,
177
    "foot",                               "--login-shell",                                           nullptr,
178
    "waybar",                                                                                        nullptr,
179
    "swaybg",                             "-m", "tile", "-i", "$HOME/images/wallpaper.png",          nullptr,
180
    "sh",                                 "-c", "wl-paste --type text --watch cliphist store",       nullptr,
181
    "sh",                                 "-c", "wl-paste --type image --watch cliphist store",      nullptr,
182
    nullptr /* End the command list. */
183
};
184
185
static const key_t keys[] = {
186
    /* Each row maps a modifier and key to an action and its optional argument. */
187
    /* modifier        key                  function           argument */
188
    { MOD,             XKB_KEY_p,           spawn,             { .v = menucmd } },
189
    { MOD | SHIFT,     XKB_KEY_Return,      spawn,             { .v = termcmd } },
190
    { MOD,             XKB_KEY_j,           focus_stack,       { .i = +1 } },
191
    { MOD,             XKB_KEY_Tab,         view,              { .i = -1 } },
192
    { MOD,             XKB_KEY_k,           focus_stack,       { .i = -1 } },
193
    { MOD,             XKB_KEY_h,           stack_config,      { .i = MASTER_SHRINK } },
194
    { MOD,             XKB_KEY_l,           stack_config,      { .i = MASTER_GROW } },
195
    { MOD,             XKB_KEY_comma,       stack_config,      { .i = MASTER_ADD } },
196
    { MOD,             XKB_KEY_period,      stack_config,      { .i = MASTER_DELETE } },
197
    { MOD | SHIFT,     XKB_KEY_less,        stack_config,      { .i = STACK_INCREMENT } },
198
    { MOD | SHIFT,     XKB_KEY_greater,     stack_config,      { .i = STACK_DECREMENT } },
199
    { MOD | SHIFT,     XKB_KEY_space,       stack_config,      { .i = STACK_RESET } },
200
    { MOD | SHIFT,     XKB_KEY_bar,         stack_config,      { .i = LAYOUT_FLIP } },
201
    { MOD | SHIFT,     XKB_KEY_j,           swap_client,       { .i = +1 } },
202
    { MOD | SHIFT,     XKB_KEY_k,           swap_client,       { .i = -1 } },
203
    { MOD,             XKB_KEY_Return,      zoom,              {} },
204
    { MOD,             XKB_KEY_m,           focus_main,        {} },
205
    { MOD,             XKB_KEY_u,           focus_urgent,      {} },
206
    { MOD,             XKB_KEY_r,           raise_client,      {} },
207
    { MOD,             XKB_KEY_a,           view,              { .i = -1 } },
208
    { MOD,             XKB_KEY_space,       cycle_layout,      {} },
209
    { MOD,             XKB_KEY_t,           toggle_floating,   {} },
210
    { MOD,             XKB_KEY_f,           toggle_max_stack,  {} },
211
    { MOD | SHIFT,     XKB_KEY_f,           toggle_fullscreen, {} },
212
    { MOD,             XKB_KEY_x,           spawn,             { .v = lockcmd } },
213
    { MOD | SHIFT,     XKB_KEY_C,           kill_client,       {} },
214
    /* Left and Right skip empty workspaces; Up and Down include them. Holding
215
     * Shift moves the focused window while cycling. */
216
    { MOD,             XKB_KEY_Right,       cycle_workspace,   { .i = WORKSPACE_NEXT } },
217
    { MOD,             XKB_KEY_Left,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS } },
218
    { MOD,             XKB_KEY_Up,          cycle_workspace,   { .i = WORKSPACE_NEXT_ALL } },
219
    { MOD,             XKB_KEY_Down,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS_ALL } },
220
    { MOD | SHIFT,     XKB_KEY_Up,          cycle_workspace,   { .i = WORKSPACE_NEXT_MOVE } },
221
    { MOD | SHIFT,     XKB_KEY_Down,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS_MOVE } },
222
    /* Shift selects a neighboring display; Control moves the focused window. */
223
    { MOD | SHIFT,     XKB_KEY_Left,        focus_monitor,     { .i = WLR_DIRECTION_LEFT } },
224
    { MOD | SHIFT,     XKB_KEY_Right,       focus_monitor,     { .i = WLR_DIRECTION_RIGHT } },
225
    { MOD | CTRL,      XKB_KEY_Left,        tag_monitor,       { .i = WLR_DIRECTION_LEFT } },
226
    { MOD | CTRL,      XKB_KEY_Right,       tag_monitor,       { .i = WLR_DIRECTION_RIGHT } },
227
    { MOD,             XKB_KEY_1,           view,              { .i = 0 } },
228
    { MOD | SHIFT,     XKB_KEY_exclam,      tag,               { .i = 0 } },
229
    { MOD,             XKB_KEY_2,           view,              { .i = 1 } },
230
    { MOD | SHIFT,     XKB_KEY_at,          tag,               { .i = 1 } },
231
    { MOD,             XKB_KEY_3,           view,              { .i = 2 } },
232
    { MOD | SHIFT,     XKB_KEY_numbersign,  tag,               { .i = 2 } },
233
    { MOD,             XKB_KEY_4,           view,              { .i = 3 } },
234
    { MOD | SHIFT,     XKB_KEY_dollar,      tag,               { .i = 3 } },
235
    { MOD,             XKB_KEY_5,           view,              { .i = 4 } },
236
    { MOD | SHIFT,     XKB_KEY_percent,     tag,               { .i = 4 } },
237
    { MOD,             XKB_KEY_6,           view,              { .i = 5 } },
238
    { MOD | SHIFT,     XKB_KEY_asciicircum, tag,               { .i = 5 } },
239
    { MOD,             XKB_KEY_7,           view,              { .i = 6 } },
240
    { MOD | SHIFT,     XKB_KEY_ampersand,   tag,               { .i = 6 } },
241
    { MOD,             XKB_KEY_8,           view,              { .i = 7 } },
242
    { MOD | SHIFT,     XKB_KEY_asterisk,    tag,               { .i = 7 } },
243
    { MOD,             XKB_KEY_9,           view,              { .i = 8 } },
244
    { MOD | SHIFT,     XKB_KEY_parenleft,   tag,               { .i = 8 } },
245
    { MOD,             XKB_KEY_0,           view,              { .i = 9 } },
246
    { MOD | SHIFT,     XKB_KEY_parenright,  tag,               { .i = 9 } },
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 } },
259
260
    /* Preserve the traditional Ctrl+Alt+Backspace shortcut for quitting. */
261
    { CTRL | ALT,      XKB_KEY_Terminate_Server, quit,      {} },
262
    /* Ctrl+Alt+Fn switches to another virtual terminal. */
263
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_1,  change_vt, { .u = 1 } },
264
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_2,  change_vt, { .u = 2 } },
265
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_3,  change_vt, { .u = 3 } },
266
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_4,  change_vt, { .u = 4 } },
267
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_5,  change_vt, { .u = 5 } },
268
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_6,  change_vt, { .u = 6 } },
269
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_7,  change_vt, { .u = 7 } },
270
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_8,  change_vt, { .u = 8 } },
271
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_9,  change_vt, { .u = 9 } },
272
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_10, change_vt, { .u = 10 } },
273
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_11, change_vt, { .u = 11 } },
274
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_12, change_vt, { .u = 12 } },
275
};
276
277
static const button_t buttons[] = {
278
    /* Hold MOD while clicking a window to move, toggle, or resize it. */
279
    /* Drag with the primary button to move the window. */
280
    { MOD, BTN_LEFT, move_resize, { .u = CURSOR_MOVE } },
281
    /* Click the middle button to toggle floating. */
282
    { MOD, BTN_MIDDLE, toggle_floating, {} },
283
    /* Drag with the secondary button to resize from the nearest corner. */
284
    { MOD, BTN_RIGHT, move_resize, { .u = CURSOR_RESIZE } },
285
};
286
// clang-format on