Add `swm` configuration

c1ac356a012a31da643ad8c3c0ce9757e0d3483f
Alexis Sellier committed ago 1 parent 0b83ef15
.config/swm/config.h added +284 -0
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 +
/* 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 touchpad's usual scrolling direction when enabled. */
105 +
static const bool natural_scrolling       = true;
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 = true;
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 +
/* Select the click button from the left or right area of the clickpad. */
119 +
static const enum libinput_config_click_method click_method =
120 +
    LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
121 +
122 +
/* Keep pointer events enabled. They can instead be disabled always or only
123 +
 * while an external mouse is connected. */
124 +
static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
125 +
126 +
/* Use a flat pointer acceleration profile. */
127 +
static const enum libinput_config_accel_profile accel_profile =
128 +
    LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
129 +
/* Pointer speed ranges from -1.0 (slowest) to 1.0 (fastest); 0.0 is neutral. */
130 +
static const double accel_speed = 0.0;
131 +
132 +
/* Map one-, two-, and three-finger taps to left, right, and middle clicks. */
133 +
static const enum libinput_config_tap_button_map button_map =
134 +
    LIBINPUT_CONFIG_TAP_MAP_LRM;
135 +
136 +
/* Commands are argument vectors and must end with nullptr. */
137 +
/* Terminal opened by MOD+Shift+Return. */
138 +
static const char *termcmd[] = { "foot", nullptr };
139 +
/* Application launcher opened by MOD+P. */
140 +
static const char *menucmd[] = { "fuzzel", nullptr };
141 +
/* Session locker started by MOD+X. */
142 +
static const char *lockcmd[] = { "swaylock", "-f", "-c", "000000", nullptr };
143 +
/* Raise, lower, or mute the default PipeWire audio sink. */
144 +
static const char *volumeupcmd[] = {
145 +
    "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%+", nullptr
146 +
};
147 +
static const char *volumedowncmd[] = {
148 +
    "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%-", nullptr
149 +
};
150 +
static const char *volumemutecmd[] = {
151 +
    "wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle", nullptr
152 +
};
153 +
/* Adjust the display and keyboard backlight brightness. */
154 +
static const char *brightnessupcmd[] = {
155 +
    "brightnessctl", "set", "10%+", nullptr
156 +
};
157 +
static const char *brightnessdowncmd[] = {
158 +
    "brightnessctl", "set", "10%-", nullptr
159 +
};
160 +
static const char *keyboardbrightnessupcmd[] = {
161 +
    "brightnessctl", "--device", "*::kbd_backlight", "set", "5%+", nullptr
162 +
};
163 +
static const char *keyboardbrightnessdowncmd[] = {
164 +
    "brightnessctl", "--device", "*::kbd_backlight", "set", "5%-", nullptr
165 +
};
166 +
/* Control media players through MPRIS. */
167 +
static const char *mediapreviouscmd[] = { "playerctl", "previous", nullptr };
168 +
static const char *medianextcmd[] = { "playerctl", "next", nullptr };
169 +
static const char *mediaplaypausecmd[] = { "playerctl", "play-pause", nullptr };
170 +
171 +
/* Run these commands once at startup. A nullptr separates commands, and a
172 +
 * second nullptr ends the list. Environment variables are expanded without
173 +
 * shell word splitting. */
174 +
static const char *const autostart[] = {
175 +
    "uwsm",                               "finalize",                                                nullptr,
176 +
    "foot",                               "--login-shell",                                           nullptr,
177 +
    "kanshi",                                                                                        nullptr,
178 +
    "swaybg",                             "-m", "tile", "-i", "$HOME/images/wallpaper.png",          nullptr,
179 +
    "sh",                                 "-c", "wl-paste --type text --watch cliphist store",       nullptr,
180 +
    "sh",                                 "-c", "wl-paste --type image --watch cliphist store",      nullptr,
181 +
    nullptr /* End the command list. */
182 +
};
183 +
184 +
static const key_t keys[] = {
185 +
    /* Each row maps a modifier and key to an action and its optional argument. */
186 +
    /* modifier        key                  function           argument */
187 +
    { MOD,             XKB_KEY_p,           spawn,             { .v = menucmd } },
188 +
    { MOD | SHIFT,     XKB_KEY_Return,      spawn,             { .v = termcmd } },
189 +
    { MOD,             XKB_KEY_j,           focus_stack,       { .i = +1 } },
190 +
    { MOD,             XKB_KEY_Tab,         view,              { .i = -1 } },
191 +
    { MOD,             XKB_KEY_k,           focus_stack,       { .i = -1 } },
192 +
    { MOD,             XKB_KEY_h,           stack_config,      { .i = MASTER_SHRINK } },
193 +
    { MOD,             XKB_KEY_l,           stack_config,      { .i = MASTER_GROW } },
194 +
    { MOD,             XKB_KEY_comma,       stack_config,      { .i = MASTER_ADD } },
195 +
    { MOD,             XKB_KEY_period,      stack_config,      { .i = MASTER_DELETE } },
196 +
    { MOD | SHIFT,     XKB_KEY_less,        stack_config,      { .i = STACK_INCREMENT } },
197 +
    { MOD | SHIFT,     XKB_KEY_greater,     stack_config,      { .i = STACK_DECREMENT } },
198 +
    { MOD | SHIFT,     XKB_KEY_space,       stack_config,      { .i = STACK_RESET } },
199 +
    { MOD | SHIFT,     XKB_KEY_bar,         stack_config,      { .i = LAYOUT_FLIP } },
200 +
    { MOD | SHIFT,     XKB_KEY_j,           swap_client,       { .i = +1 } },
201 +
    { MOD | SHIFT,     XKB_KEY_k,           swap_client,       { .i = -1 } },
202 +
    { MOD,             XKB_KEY_Return,      zoom,              {} },
203 +
    { MOD,             XKB_KEY_m,           focus_main,        {} },
204 +
    { MOD,             XKB_KEY_u,           focus_urgent,      {} },
205 +
    { MOD,             XKB_KEY_r,           raise_client,      {} },
206 +
    { MOD,             XKB_KEY_a,           view,              { .i = -1 } },
207 +
    { MOD,             XKB_KEY_space,       cycle_layout,      {} },
208 +
    { MOD,             XKB_KEY_t,           toggle_floating,   {} },
209 +
    { MOD,             XKB_KEY_f,           toggle_max_stack,  {} },
210 +
    { MOD | SHIFT,     XKB_KEY_f,           toggle_fullscreen, {} },
211 +
    { MOD,             XKB_KEY_x,           spawn,             { .v = lockcmd } },
212 +
    { MOD | SHIFT,     XKB_KEY_C,           kill_client,       {} },
213 +
    /* Left and Right skip empty workspaces; Up and Down include them. Holding
214 +
     * Shift moves the focused window while cycling. */
215 +
    { MOD,             XKB_KEY_Right,       cycle_workspace,   { .i = WORKSPACE_NEXT } },
216 +
    { MOD,             XKB_KEY_Left,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS } },
217 +
    { MOD,             XKB_KEY_Up,          cycle_workspace,   { .i = WORKSPACE_NEXT_ALL } },
218 +
    { MOD,             XKB_KEY_Down,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS_ALL } },
219 +
    { MOD | SHIFT,     XKB_KEY_Up,          cycle_workspace,   { .i = WORKSPACE_NEXT_MOVE } },
220 +
    { MOD | SHIFT,     XKB_KEY_Down,        cycle_workspace,   { .i = WORKSPACE_PREVIOUS_MOVE } },
221 +
    /* Shift selects a neighboring display; Control moves the focused window. */
222 +
    { MOD | SHIFT,     XKB_KEY_Left,        focus_monitor,     { .i = WLR_DIRECTION_LEFT } },
223 +
    { MOD | SHIFT,     XKB_KEY_Right,       focus_monitor,     { .i = WLR_DIRECTION_RIGHT } },
224 +
    { MOD | CTRL,      XKB_KEY_Left,        tag_monitor,       { .i = WLR_DIRECTION_LEFT } },
225 +
    { MOD | CTRL,      XKB_KEY_Right,       tag_monitor,       { .i = WLR_DIRECTION_RIGHT } },
226 +
    { MOD,             XKB_KEY_1,           view,              { .i = 0 } },
227 +
    { MOD | SHIFT,     XKB_KEY_exclam,      tag,               { .i = 0 } },
228 +
    { MOD,             XKB_KEY_2,           view,              { .i = 1 } },
229 +
    { MOD | SHIFT,     XKB_KEY_at,          tag,               { .i = 1 } },
230 +
    { MOD,             XKB_KEY_3,           view,              { .i = 2 } },
231 +
    { MOD | SHIFT,     XKB_KEY_numbersign,  tag,               { .i = 2 } },
232 +
    { MOD,             XKB_KEY_4,           view,              { .i = 3 } },
233 +
    { MOD | SHIFT,     XKB_KEY_dollar,      tag,               { .i = 3 } },
234 +
    { MOD,             XKB_KEY_5,           view,              { .i = 4 } },
235 +
    { MOD | SHIFT,     XKB_KEY_percent,     tag,               { .i = 4 } },
236 +
    { MOD,             XKB_KEY_6,           view,              { .i = 5 } },
237 +
    { MOD | SHIFT,     XKB_KEY_asciicircum, tag,               { .i = 5 } },
238 +
    { MOD,             XKB_KEY_7,           view,              { .i = 6 } },
239 +
    { MOD | SHIFT,     XKB_KEY_ampersand,   tag,               { .i = 6 } },
240 +
    { MOD,             XKB_KEY_8,           view,              { .i = 7 } },
241 +
    { MOD | SHIFT,     XKB_KEY_asterisk,    tag,               { .i = 7 } },
242 +
    { MOD,             XKB_KEY_9,           view,              { .i = 8 } },
243 +
    { MOD | SHIFT,     XKB_KEY_parenleft,   tag,               { .i = 8 } },
244 +
    { MOD,             XKB_KEY_0,           view,              { .i = 9 } },
245 +
    { MOD | SHIFT,     XKB_KEY_parenright,  tag,               { .i = 9 } },
246 +
    { MOD | SHIFT,     XKB_KEY_q,           quit,              {} },
247 +
    /* Hardware keys control audio, backlights, and media without a modifier. */
248 +
    { 0,               XKB_KEY_XF86AudioRaiseVolume,   spawn, { .v = volumeupcmd } },
249 +
    { 0,               XKB_KEY_XF86AudioLowerVolume,   spawn, { .v = volumedowncmd } },
250 +
    { 0,               XKB_KEY_XF86AudioMute,          spawn, { .v = volumemutecmd } },
251 +
    { 0,               XKB_KEY_XF86MonBrightnessUp,    spawn, { .v = brightnessupcmd } },
252 +
    { 0,               XKB_KEY_XF86MonBrightnessDown,  spawn, { .v = brightnessdowncmd } },
253 +
    { 0,               XKB_KEY_XF86KbdBrightnessUp,    spawn, { .v = keyboardbrightnessupcmd } },
254 +
    { 0,               XKB_KEY_XF86KbdBrightnessDown,  spawn, { .v = keyboardbrightnessdowncmd } },
255 +
    { 0,               XKB_KEY_XF86AudioPrev,          spawn, { .v = mediapreviouscmd } },
256 +
    { 0,               XKB_KEY_XF86AudioNext,          spawn, { .v = medianextcmd } },
257 +
    { 0,               XKB_KEY_XF86AudioPlay,          spawn, { .v = mediaplaypausecmd } },
258 +
259 +
    /* Preserve the traditional Ctrl+Alt+Backspace shortcut for quitting. */
260 +
    { CTRL | ALT,      XKB_KEY_Terminate_Server, quit,      {} },
261 +
    /* Ctrl+Alt+Fn switches to another virtual terminal. */
262 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_1,  change_vt, { .u = 1 } },
263 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_2,  change_vt, { .u = 2 } },
264 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_3,  change_vt, { .u = 3 } },
265 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_4,  change_vt, { .u = 4 } },
266 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_5,  change_vt, { .u = 5 } },
267 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_6,  change_vt, { .u = 6 } },
268 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_7,  change_vt, { .u = 7 } },
269 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_8,  change_vt, { .u = 8 } },
270 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_9,  change_vt, { .u = 9 } },
271 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_10, change_vt, { .u = 10 } },
272 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_11, change_vt, { .u = 11 } },
273 +
    { CTRL | ALT,      XKB_KEY_XF86Switch_VT_12, change_vt, { .u = 12 } },
274 +
};
275 +
276 +
static const button_t buttons[] = {
277 +
    /* Hold MOD while clicking a window to move, toggle, or resize it. */
278 +
    /* Drag with the primary button to move the window. */
279 +
    { MOD, BTN_LEFT, move_resize, { .u = CURSOR_MOVE } },
280 +
    /* Click the middle button to toggle floating. */
281 +
    { MOD, BTN_MIDDLE, toggle_floating, {} },
282 +
    /* Drag with the secondary button to resize from the nearest corner. */
283 +
    { MOD, BTN_RIGHT, move_resize, { .u = CURSOR_RESIZE } },
284 +
};