nix machine / user configurations
1// This config is in the KDL format: https://kdl.dev 2// "/-" comments out the following node. 3// Check the wiki for a full description of the configuration: 4// https://yalter.github.io/niri/Configuration:-Introduction 5 6// Input device configuration. 7// Find the full list of options on the wiki: 8// https://yalter.github.io/niri/Configuration:-Input 9input { 10 keyboard { 11 xkb { 12 // You can set rules, model, layout, variant and options. 13 // For more information, see xkeyboard-config(7). 14 15 // For example: 16 // layout "us,ru" 17 // options "grp:win_space_toggle,compose:ralt,ctrl:nocaps" 18 options "compose:ralt" 19 20 // If this section is empty, niri will fetch xkb settings 21 // from org.freedesktop.locale1. You can control these using 22 // localectl set-x11-keymap. 23 } 24 25 // Enable numlock on startup, omitting this setting disables it. 26 // numlock 27 } 28 29 touchpad { 30 // off 31 tap 32 // dwt 33 // dwtp 34 // drag false 35 // drag-lock 36 natural-scroll 37 // accel-speed 0.2 38 accel-profile "flat" 39 // scroll-method "two-finger" 40 // disabled-on-external-mouse 41 } 42 43 mouse { 44 // off 45 // natural-scroll 46 // accel-speed 0.2 47 accel-profile "flat" 48 // scroll-method "no-scroll" 49 } 50 51 trackpoint { 52 // off 53 // natural-scroll 54 // accel-speed 0.2 55 accel-profile "flat" 56 // scroll-method "on-button-down" 57 // scroll-button 273 58 // scroll-button-lock 59 // middle-emulation 60 } 61 62 warp-mouse-to-focus 63 focus-follows-mouse max-scroll-amount="0%" 64 65 mod-key "Super" 66 mod-key-nested "Alt" 67} 68 69output "HDMI-A-2" { 70 mode "1920x1080@74.973" 71 scale 1 72} 73 74output "DP-1" { 75 mode "1920x1080@165.009" 76 scale 1 77} 78 79// Settings that influence how windows are positioned and sized. 80// Find more information on the wiki: 81// https://yalter.github.io/niri/Configuration:-Layout 82layout { 83 // Set gaps around windows in logical pixels. 84 gaps 0 85 86 // When to center a column when changing focus, options are: 87 // - "never", default behavior, focusing an off-screen column will keep at the left 88 // or right edge of the screen. 89 // - "always", the focused column will always be centered. 90 // - "on-overflow", focusing a column will center it if it doesn't fit 91 // together with the previously focused column. 92 center-focused-column "never" 93 94 // You can customize the widths that "switch-preset-column-width" (Mod+R) toggles between. 95 preset-column-widths { 96 // Proportion sets the width as a fraction of the output width, taking gaps into account. 97 // For example, you can perfectly fit four windows sized "proportion 0.25" on an output. 98 // The default preset widths are 1/3, 1/2 and 2/3 of the output. 99 proportion 0.33333 100 proportion 0.5 101 proportion 0.66667 102 103 // Fixed sets the width in logical pixels exactly. 104 // fixed 1920 105 } 106 107 // default-column-width { proportion 1.0; } 108 109 focus-ring { off; } 110 border { off; } 111 // shadow { off; } 112 113 struts { } 114} 115 116spawn-at-startup "swaybg" "-i" "%%wallpaper%%" 117 118hotkey-overlay { 119 // skip-at-startup 120} 121 122prefer-no-csd 123 124screenshot-path "~/shots/%Y-%m-%d_%H-%M-%S.png" 125 126environment { 127 ELECTRON_OZONE_PLATFORM_HINT "auto" 128} 129 130animations { 131 // off 132 133 // Slow down all animations by this factor. Values below 1 speed them up instead. 134 slowdown 1.4 135} 136 137// Open the Firefox picture-in-picture player as floating by default. 138window-rule { 139 // This app-id regular expression will work for both: 140 // - host Firefox (app-id is "firefox") 141 // - Flatpak Firefox (app-id is "org.mozilla.firefox") 142 match app-id=r#"firefox$"# title="^Picture-in-Picture$" 143 144 open-floating true 145} 146 147window-rule { 148 match app-id=r#"^org\.keepassxc\.KeePassXC$"# 149 match app-id=r#"^org\.gnome\.World\.Secrets$"# 150 // match namespace="^notifications$" 151 152 block-out-from "screen-capture" 153} 154 155window-rule { 156 match app-id="steam" title=r#"^notificationtoasts_\d+_desktop$"# 157 default-floating-position x=10 y=10 relative-to="bottom-right" 158} 159 160window-rule { 161 geometry-corner-radius 0 162 clip-to-geometry true 163} 164 165binds { 166 Mod+Shift+Slash { show-hotkey-overlay; } 167 168 Mod+Return hotkey-overlay-title="terminal: foot" { spawn "footclient"; } 169 Mod+D hotkey-overlay-title="launcher: wofi" { spawn "tofi-drun"; } 170 171 Alt+S hotkey-overlay-title="screenshot screen" { screenshot-screen; } 172 Alt+Shift+S hotkey-overlay-title="screenshot" { screenshot; } 173 174 XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+"; } 175 XF86AudioLowerVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; } 176 XF86AudioMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; } 177 XF86AudioMicMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; } 178 179 XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; } 180 XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; } 181 182 Mod+O repeat=false { toggle-overview; } 183 Mod+Q cooldown-ms=50 { close-window; } 184 185 Mod+Left { focus-column-left; } 186 Mod+Down { focus-window-down; } 187 Mod+Up { focus-window-up; } 188 Mod+Right { focus-column-right; } 189 Mod+H { focus-column-left; } 190 Mod+J { focus-window-down; } 191 Mod+K { focus-window-up; } 192 Mod+L { focus-column-right; } 193 194 Mod+Shift+Left { move-column-left; } 195 Mod+Shift+Down { move-window-down; } 196 Mod+Shift+Up { move-window-up; } 197 Mod+Shift+Right { move-column-right; } 198 Mod+Shift+H { move-column-left; } 199 Mod+Shift+J { move-window-down; } 200 Mod+Shift+K { move-window-up; } 201 Mod+Shift+L { move-column-right; } 202 203 // Alternative commands that move across workspaces when reaching 204 // the first or last window in a column. 205 // Mod+J { focus-window-or-workspace-down; } 206 // Mod+K { focus-window-or-workspace-up; } 207 // Mod+Ctrl+J { move-window-down-or-to-workspace-down; } 208 // Mod+Ctrl+K { move-window-up-or-to-workspace-up; } 209 210 Mod+Home { focus-column-first; } 211 Mod+End { focus-column-last; } 212 Mod+Ctrl+Home { move-column-to-first; } 213 Mod+Ctrl+End { move-column-to-last; } 214 215 Mod+Ctrl+Left { focus-monitor-left; } 216 Mod+Ctrl+Down { focus-monitor-down; } 217 Mod+Ctrl+Up { focus-monitor-up; } 218 Mod+Ctrl+Right { focus-monitor-right; } 219 Mod+Ctrl+H { focus-monitor-left; } 220 Mod+Ctrl+J { focus-monitor-down; } 221 Mod+Ctrl+K { focus-monitor-up; } 222 Mod+Ctrl+L { focus-monitor-right; } 223 224 Mod+Shift+Ctrl+Left { move-column-to-monitor-left; } 225 Mod+Shift+Ctrl+Down { move-column-to-monitor-down; } 226 Mod+Shift+Ctrl+Up { move-column-to-monitor-up; } 227 Mod+Shift+Ctrl+Right { move-column-to-monitor-right; } 228 Mod+Shift+Ctrl+H { move-column-to-monitor-left; } 229 Mod+Shift+Ctrl+J { move-column-to-monitor-down; } 230 Mod+Shift+Ctrl+K { move-column-to-monitor-up; } 231 Mod+Shift+Ctrl+L { move-column-to-monitor-right; } 232 233 Mod+Page_Down { focus-workspace-down; } 234 Mod+Page_Up { focus-workspace-up; } 235 //Mod+U { focus-workspace-down; } 236 //Mod+I { focus-workspace-up; } 237 Mod+Ctrl+Page_Down { move-column-to-workspace-down; } 238 Mod+Ctrl+Page_Up { move-column-to-workspace-up; } 239 //Mod+Ctrl+U { move-column-to-workspace-down; } 240 //Mod+Ctrl+I { move-column-to-workspace-up; } 241 242 Mod+Shift+Page_Down { move-workspace-down; } 243 Mod+Shift+Page_Up { move-workspace-up; } 244 Mod+Shift+U { move-workspace-down; } 245 Mod+Shift+I { move-workspace-up; } 246 247 // You can bind mouse wheel scroll ticks using the following syntax. 248 // These binds will change direction based on the natural-scroll setting. 249 // 250 // To avoid scrolling through workspaces really fast, you can use 251 // the cooldown-ms property. The bind will be rate-limited to this value. 252 // You can set a cooldown on any bind, but it's most useful for the wheel. 253 Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; } 254 Mod+WheelScrollUp cooldown-ms=150 { focus-workspace-up; } 255 Mod+Shift+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; } 256 Mod+Shift+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; } 257 258 // Usually scrolling up and down with Shift in applications results in 259 // horizontal scrolling; these binds replicate that. 260 Alt+WheelScrollDown { focus-column-right; } 261 Alt+WheelScrollUp { focus-column-left; } 262 Alt+Shift+WheelScrollDown { move-column-right; } 263 Alt+Shift+WheelScrollUp { move-column-left; } 264 265 Mod+1 { focus-workspace 1; } 266 Mod+2 { focus-workspace 2; } 267 Mod+3 { focus-workspace 3; } 268 Mod+4 { focus-workspace 4; } 269 Mod+5 { focus-workspace 5; } 270 Mod+6 { focus-workspace 6; } 271 Mod+7 { focus-workspace 7; } 272 Mod+8 { focus-workspace 8; } 273 Mod+9 { focus-workspace 9; } 274 Mod+Ctrl+1 { move-column-to-workspace 1; } 275 Mod+Ctrl+2 { move-column-to-workspace 2; } 276 Mod+Ctrl+3 { move-column-to-workspace 3; } 277 Mod+Ctrl+4 { move-column-to-workspace 4; } 278 Mod+Ctrl+5 { move-column-to-workspace 5; } 279 Mod+Ctrl+6 { move-column-to-workspace 6; } 280 Mod+Ctrl+7 { move-column-to-workspace 7; } 281 Mod+Ctrl+8 { move-column-to-workspace 8; } 282 Mod+Ctrl+9 { move-column-to-workspace 9; } 283 284 // Switches focus between the current and the previous workspace. 285 // Mod+Tab { focus-workspace-previous; } 286 287 // The following binds move the focused window in and out of a column. 288 // If the window is alone, they will consume it into the nearby column to the side. 289 // If the window is already in a column, they will expel it out. 290 Mod+BracketLeft { consume-or-expel-window-left; } 291 Mod+BracketRight { consume-or-expel-window-right; } 292 293 // Consume one window from the right to the bottom of the focused column. 294 Mod+Comma { consume-window-into-column; } 295 // Expel the bottom window from the focused column to the right. 296 Mod+Period { expel-window-from-column; } 297 298 Mod+R { switch-preset-column-width; } 299 // Cycling through the presets in reverse order is also possible. 300 // Mod+R { switch-preset-column-width-back; } 301 Mod+Shift+R { switch-preset-window-height; } 302 Mod+Ctrl+R { reset-window-height; } 303 Mod+F { maximize-column; } 304 Mod+Shift+F { fullscreen-window; } 305 306 // Expand the focused column to space not taken up by other fully visible columns. 307 // Makes the column "fill the rest of the space". 308 Mod+Ctrl+F { expand-column-to-available-width; } 309 310 Mod+C { center-column; } 311 312 // Center all fully visible columns on screen. 313 Mod+Ctrl+C { center-visible-columns; } 314 315 // Finer width adjustments. 316 // This command can also: 317 // * set width in pixels: "1000" 318 // * adjust width in pixels: "-5" or "+5" 319 // * set width as a percentage of screen width: "25%" 320 // * adjust width as a percentage of screen width: "-10%" or "+10%" 321 // Pixel sizes use logical, or scaled, pixels. I.e. on an output with scale 2.0, 322 // set-column-width "100" will make the column occupy 200 physical screen pixels. 323 Mod+Minus { set-column-width "-10%"; } 324 Mod+Equal { set-column-width "+10%"; } 325 326 // Finer height adjustments when in column with other windows. 327 Mod+Shift+Minus { set-window-height "-10%"; } 328 Mod+Shift+Equal { set-window-height "+10%"; } 329 330 // Move the focused window between the floating and the tiling layout. 331 Mod+V { toggle-window-floating; } 332 Mod+Shift+V { switch-focus-between-floating-and-tiling; } 333 334 // Toggle tabbed column display mode. 335 // Windows in this column will appear as vertical tabs, 336 // rather than stacked on top of each other. 337 Mod+W { toggle-column-tabbed-display; } 338 339 // Actions to switch layouts. 340 // Note: if you uncomment these, make sure you do NOT have 341 // a matching layout switch hotkey configured in xkb options above. 342 // Having both at once on the same hotkey will break the switching, 343 // since it will switch twice upon pressing the hotkey (once by xkb, once by niri). 344 // Mod+Space { switch-layout "next"; } 345 // Mod+Shift+Space { switch-layout "prev"; } 346 347 // Applications such as remote-desktop clients and software KVM switches may 348 // request that niri stops processing the keyboard shortcuts defined here 349 // so they may, for example, forward the key presses as-is to a remote machine. 350 // It's a good idea to bind an escape hatch to toggle the inhibitor, 351 // so a buggy application can't hold your session hostage. 352 // 353 // The allow-inhibiting=false property can be applied to other binds as well, 354 // which ensures niri always processes them, even when an inhibitor is active. 355 Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; } 356 357 // The quit action will show a confirmation dialog to avoid accidental exits. 358 Mod+Shift+E { quit; } 359 Ctrl+Alt+Delete { quit; } 360 361 // Powers off the monitors. To turn them back on, do any input like 362 // moving the mouse or pressing any other key. 363 Mod+Shift+P { power-off-monitors; } 364}