.config/swm/config.h 16.3 KiB raw
1
/* Short names used to compose modifiers in the key and button tables. */
2
#define MOD   WLR_MODIFIER_LOGO
3
#define SHIFT WLR_MODIFIER_SHIFT
4
#define CTRL  WLR_MODIFIER_CTRL
5
#define ALT   WLR_MODIFIER_ALT
6
7
/* Create this many numbered workspaces. Valid values are 1 through 32. */
8
#define WSCOUNT (10)
9
10
/* Convert an 0xRRGGBBAA color to the floating-point format used by wlroots. */
11
#define RGBA(hex)                                                              \
12
    { ((hex >> 24) & 0xFF) / 255.0f,                                           \
13
      ((hex >> 16) & 0xFF) / 255.0f,                                           \
14
      ((hex >> 8)  & 0xFF) / 255.0f,                                           \
15
       (hex        & 0xFF) / 255.0f }
16
17
/* Focus follows the pointer when enabled. */
18
static const bool         sloppyfocus   = true;
19
/* Borders are measured in physical layout pixels. */
20
static const unsigned int borderwidth   = 1;
21
/* Fill uncovered parts of the desktop with this color. */
22
static const float        rootcolor[]   = RGBA(0x222222ff);
23
/* Draw this color around an unfocused window. */
24
static const float        bordercolor[] = RGBA(0x101010ff);
25
/* Draw this color around the focused window. */
26
static const float        focuscolor[]  = RGBA(0x404040ff);
27
/* Draw this color around a window requesting attention. */
28
static const float        urgentcolor[] = RGBA(0xb03060ff);
29
/* Place this translucent color behind matching layer surfaces. */
30
static const float        dimcolor[]    = RGBA(0x00000080);
31
32
/* This background hides other windows behind transparent fullscreen content,
33
 * as required by the XDG shell protocol. Set its alpha to zero to disable it. */
34
static const float fullscreen_bg[] = {
35
    0.0f, 0.0f, 0.0f, 1.0f
36
};
37
38
/* Report errors only. Use WLR_DEBUG for detailed wlroots diagnostics. */
39
static int log_level = WLR_ERROR;
40
/* Apply an atomic layout after this many milliseconds if a client is unresponsive. */
41
static const int transaction_timeout_ms = 200;
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, 2.0, WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
77
    /* Keep at least one fallback rule. */
78
};
79
80
/* Keyboard rules match the exact device name. The final rule must have a null
81
 * name and applies to keyboards without a named rule. */
82
static const keyboard_rule_t keyboardrules[] = {
83
    {
84
        .name = "AT Translated Set 2 keyboard",
85
        .xkb = {
86
            /* XKB layout name. */
87
            .layout  = "us",
88
            /* Layout variant; altgr-intl provides international characters via AltGr. */
89
            .variant = "altgr-intl",
90
            /* Comma-separated XKB options, or nullptr for none. */
91
            .options = "altwin:swap_alt_win",
92
        },
93
    },
94
    {
95
        .name = nullptr,
96
        .xkb = {
97
            /* XKB layout name. */
98
            .layout  = "us",
99
            /* Layout variant; altgr-intl provides international characters via AltGr. */
100
            .variant = "altgr-intl",
101
            /* Comma-separated XKB options, or nullptr for none. */
102
            .options = nullptr,
103
        },
104
    },
105
};
106
107
/* Repeat a held key this many times per second. */
108
static const int repeat_rate  = 40;
109
/* Wait this many milliseconds before a held key starts repeating. */
110
static const int repeat_delay = 180;
111
112
/* Pointer and touchpad behavior. Unsupported options are ignored per device. */
113
/* Resize a tiled split within this distance from its boundary, in pixels. */
114
static const unsigned tiled_resize_margin = 4;
115
/* Tap the touchpad to produce a click. */
116
static const bool tap_to_click            = true;
117
/* Keep a tapped item grabbed while the finger moves. */
118
static const bool tap_and_drag            = true;
119
/* Keep dragging after the finger is briefly lifted and placed down again. */
120
static const bool drag_lock               = true;
121
/* Reverse the touchpad's usual scrolling direction when enabled. */
122
static const bool natural_scrolling       = true;
123
/* Ignore touchpad input while typing. */
124
static const bool disable_while_typing    = true;
125
/* Swap the primary and secondary pointer buttons when enabled. */
126
static const bool left_handed             = false;
127
/* Press the left and right buttons together to produce a middle click. */
128
static const bool middle_button_emulation = true;
129
130
/* Scroll with two fingers. Other choices are NO_SCROLL, EDGE, and
131
 * ON_BUTTON_DOWN. */
132
static const enum libinput_config_scroll_method scroll_method =
133
    LIBINPUT_CONFIG_SCROLL_2FG;
134
135
/* Select the click button from the left or right area of the clickpad. */
136
static const enum libinput_config_click_method click_method =
137
    LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
138
139
/* Keep pointer events enabled. They can instead be disabled always or only
140
 * while an external mouse is connected. */
141
static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
142
143
/* Use a flat pointer acceleration profile. */
144
static const enum libinput_config_accel_profile accel_profile =
145
    LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
146
/* Pointer speed ranges from -1.0 (slowest) to 1.0 (fastest); 0.0 is neutral. */
147
static const double accel_speed = 0.0;
148
149
/* Map one-, two-, and three-finger taps to left, right, and middle clicks. */
150
static const enum libinput_config_tap_button_map button_map =
151
    LIBINPUT_CONFIG_TAP_MAP_LRM;
152
153
/* Commands are argument vectors and must end with nullptr. */
154
/* Terminal opened by MOD+Shift+Return. */
155
static const char *termcmd[] = { "foot", nullptr };
156
/* Application launcher opened by MOD+P. */
157
static const char *menucmd[] = { "fuzzel", nullptr };
158
/* Session locker started by MOD+X. */
159
static const char *lockcmd[] = { "swaylock", "-f", "-c", "000000", nullptr };
160
/* Raise, lower, or mute the default PipeWire audio sink. */
161
static const char *volumeupcmd[] = {
162
    "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%+", nullptr
163
};
164
static const char *volumedowncmd[] = {
165
    "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%-", nullptr
166
};
167
static const char *volumemutecmd[] = {
168
    "wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle", nullptr
169
};
170
/* Adjust the display and keyboard backlight brightness. */
171
static const char *brightnessupcmd[] = {
172
    "brightnessctl", "set", "10%+", nullptr
173
};
174
static const char *brightnessdowncmd[] = {
175
    "brightnessctl", "set", "10%-", nullptr
176
};
177
static const char *keyboardbrightnessupcmd[] = {
178
    "brightnessctl", "--device", "*::kbd_backlight", "set", "5%+", nullptr
179
};
180
static const char *keyboardbrightnessdowncmd[] = {
181
    "brightnessctl", "--device", "*::kbd_backlight", "set", "5%-", nullptr
182
};
183
/* Control media players through MPRIS. */
184
static const char *mediapreviouscmd[] = { "playerctl", "previous", nullptr };
185
static const char *medianextcmd[] = { "playerctl", "next", nullptr };
186
static const char *mediaplaypausecmd[] = { "playerctl", "play-pause", nullptr };
187
188
/* Run these commands once at startup. A nullptr separates commands, and a
189
 * second nullptr ends the list. Environment variables are expanded without
190
 * shell word splitting. */
191
static const char *const autostart[] = {
192
    "uwsm",                               "finalize",                                                nullptr,
193
    "foot",                               "--login-shell",                                           nullptr,
194
    "kanshi",                                                                                        nullptr,
195
    "swaybg",                             "-m", "tile", "-i", "$HOME/images/wallpaper.png",          nullptr,
196
    "sh",                                 "-c", "wl-paste --type text --watch cliphist store",       nullptr,
197
    "sh",                                 "-c", "wl-paste --type image --watch cliphist store",      nullptr,
198
    nullptr /* End the command list. */
199
};
200
201
static const key_t keys[] = {
202
    /* Each row maps a modifier and key to an action and its optional argument. */
203
    /* modifier        key                  function           argument */
204
    { MOD,             XKB_KEY_p,           spawn,             { .v = menucmd } },
205
    { MOD | SHIFT,     XKB_KEY_Return,      spawn,             { .v = termcmd } },
206
    { MOD,             XKB_KEY_j,           focus_stack,       { .i = +1 } },
207
    { MOD,             XKB_KEY_Tab,         view,              { .i = -1 } },
208
    { MOD,             XKB_KEY_k,           focus_stack,       { .i = -1 } },
209
    { MOD,             XKB_KEY_h,           stack_config,      { .i = MASTER_SHRINK } },
210
    { MOD,             XKB_KEY_l,           stack_config,      { .i = MASTER_GROW } },
211
    { MOD,             XKB_KEY_comma,       stack_config,      { .i = MASTER_ADD } },
212
    { MOD,             XKB_KEY_period,      stack_config,      { .i = MASTER_DELETE } },
213
    { MOD | SHIFT,     XKB_KEY_less,        stack_config,      { .i = STACK_INCREMENT } },
214
    { MOD | SHIFT,     XKB_KEY_greater,     stack_config,      { .i = STACK_DECREMENT } },
215
    { MOD | SHIFT,     XKB_KEY_space,       stack_config,      { .i = STACK_RESET } },
216
    { MOD | SHIFT,     XKB_KEY_bar,         stack_config,      { .i = LAYOUT_FLIP } },
217
    { MOD | SHIFT,     XKB_KEY_j,           swap_client,       { .i = +1 } },
218
    { MOD | SHIFT,     XKB_KEY_k,           swap_client,       { .i = -1 } },
219
    { MOD,             XKB_KEY_Return,      zoom,              {} },
220
    { MOD,             XKB_KEY_m,           focus_main,        {} },
221
    { MOD,             XKB_KEY_u,           focus_urgent,      {} },
222
    { MOD,             XKB_KEY_r,           raise_client,      {} },
223
    { MOD,             XKB_KEY_a,           view,              { .i = -1 } },
224
    { MOD,             XKB_KEY_space,       cycle_layout,      {} },
225
    { MOD,             XKB_KEY_t,           toggle_floating,   {} },
226
    { MOD,             XKB_KEY_f,           toggle_max_stack,  {} },
227
    { MOD | SHIFT,     XKB_KEY_f,           toggle_fullscreen, {} },
228
    { MOD,             XKB_KEY_x,           spawn,             { .v = lockcmd } },
229
    { MOD | SHIFT,     XKB_KEY_C,           kill_client,       {} },
230
    /* Left and Right skip empty workspaces; Up and Down include them. Holding
231
     * Shift moves the focused window while cycling. */
232
    { MOD,             XKB_KEY_Right,       cycle_workspace,   { .i = WORKSPACE_NEXT } },
233
    { MOD,             XKB_KEY_Left,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS } },
234
    { MOD,             XKB_KEY_Up,          cycle_workspace,   { .i = WORKSPACE_NEXT_ALL } },
235
    { MOD,             XKB_KEY_Down,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS_ALL } },
236
    { MOD | SHIFT,     XKB_KEY_Up,          cycle_workspace,   { .i = WORKSPACE_NEXT_MOVE } },
237
    { MOD | SHIFT,     XKB_KEY_Down,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS_MOVE } },
238
    /* Shift selects a neighboring display; Control moves the focused window. */
239
    { MOD | SHIFT,     XKB_KEY_Left,        focus_monitor,     { .i = WLR_DIRECTION_LEFT } },
240
    { MOD | SHIFT,     XKB_KEY_Right,       focus_monitor,     { .i = WLR_DIRECTION_RIGHT } },
241
    { MOD | CTRL,      XKB_KEY_Left,        tag_monitor,       { .i = WLR_DIRECTION_LEFT } },
242
    { MOD | CTRL,      XKB_KEY_Right,       tag_monitor,       { .i = WLR_DIRECTION_RIGHT } },
243
    { MOD,             XKB_KEY_1,           view,              { .i = 0 } },
244
    { MOD | SHIFT,     XKB_KEY_exclam,      tag,               { .i = 0 } },
245
    { MOD,             XKB_KEY_2,           view,              { .i = 1 } },
246
    { MOD | SHIFT,     XKB_KEY_at,          tag,               { .i = 1 } },
247
    { MOD,             XKB_KEY_3,           view,              { .i = 2 } },
248
    { MOD | SHIFT,     XKB_KEY_numbersign,  tag,               { .i = 2 } },
249
    { MOD,             XKB_KEY_4,           view,              { .i = 3 } },
250
    { MOD | SHIFT,     XKB_KEY_dollar,      tag,               { .i = 3 } },
251
    { MOD,             XKB_KEY_5,           view,              { .i = 4 } },
252
    { MOD | SHIFT,     XKB_KEY_percent,     tag,               { .i = 4 } },
253
    { MOD,             XKB_KEY_6,           view,              { .i = 5 } },
254
    { MOD | SHIFT,     XKB_KEY_asciicircum, tag,               { .i = 5 } },
255
    { MOD,             XKB_KEY_7,           view,              { .i = 6 } },
256
    { MOD | SHIFT,     XKB_KEY_ampersand,   tag,               { .i = 6 } },
257
    { MOD,             XKB_KEY_8,           view,              { .i = 7 } },
258
    { MOD | SHIFT,     XKB_KEY_asterisk,    tag,               { .i = 7 } },
259
    { MOD,             XKB_KEY_9,           view,              { .i = 8 } },
260
    { MOD | SHIFT,     XKB_KEY_parenleft,   tag,               { .i = 8 } },
261
    { MOD,             XKB_KEY_0,           view,              { .i = 9 } },
262
    { MOD | SHIFT,     XKB_KEY_parenright,  tag,               { .i = 9 } },
263
    { MOD | SHIFT,     XKB_KEY_q,           quit,              {} },
264
    /* Hardware keys control audio, backlights, and media without a modifier. */
265
    { 0,               XKB_KEY_XF86AudioRaiseVolume,   spawn, { .v = volumeupcmd } },
266
    { 0,               XKB_KEY_XF86AudioLowerVolume,   spawn, { .v = volumedowncmd } },
267
    { 0,               XKB_KEY_XF86AudioMute,          spawn, { .v = volumemutecmd } },
268
    { 0,               XKB_KEY_XF86MonBrightnessUp,    spawn, { .v = brightnessupcmd } },
269
    { 0,               XKB_KEY_XF86MonBrightnessDown,  spawn, { .v = brightnessdowncmd } },
270
    { 0,               XKB_KEY_XF86KbdBrightnessUp,    spawn, { .v = keyboardbrightnessupcmd } },
271
    { 0,               XKB_KEY_XF86KbdBrightnessDown,  spawn, { .v = keyboardbrightnessdowncmd } },
272
    { 0,               XKB_KEY_XF86AudioPrev,          spawn, { .v = mediapreviouscmd } },
273
    { 0,               XKB_KEY_XF86AudioNext,          spawn, { .v = medianextcmd } },
274
    { 0,               XKB_KEY_XF86AudioPlay,          spawn, { .v = mediaplaypausecmd } },
275
276
    /* Preserve the traditional Ctrl+Alt+Backspace shortcut for quitting. */
277
    { CTRL | ALT,      XKB_KEY_Terminate_Server, quit,      {} },
278
    /* Ctrl+Alt+Fn switches to another virtual terminal. */
279
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_1,  change_vt, { .u = 1 } },
280
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_2,  change_vt, { .u = 2 } },
281
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_3,  change_vt, { .u = 3 } },
282
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_4,  change_vt, { .u = 4 } },
283
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_5,  change_vt, { .u = 5 } },
284
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_6,  change_vt, { .u = 6 } },
285
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_7,  change_vt, { .u = 7 } },
286
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_8,  change_vt, { .u = 8 } },
287
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_9,  change_vt, { .u = 9 } },
288
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_10, change_vt, { .u = 10 } },
289
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_11, change_vt, { .u = 11 } },
290
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_12, change_vt, { .u = 12 } },
291
};
292
293
static const button_t buttons[] = {
294
    /* Hold MOD while clicking a window to move, toggle, or resize it. */
295
    /* Drag with the primary button to move the window. */
296
    { MOD, BTN_LEFT, move_resize, { .u = CURSOR_MOVE } },
297
    /* Click the middle button to toggle floating. */
298
    { MOD, BTN_MIDDLE, toggle_floating, {} },
299
    /* Drag with the secondary button to resize from the nearest corner. */
300
    { MOD, BTN_RIGHT, move_resize, { .u = CURSOR_RESIZE } },
301
};