From 8e115fb9690a85e7365b31521a098843985406b4 Mon Sep 17 00:00:00 2001 From: Kabbone Date: Mon, 29 Jun 2026 11:06:14 +0200 Subject: [PATCH] split up niri config for dekstop and laptop --- hosts/home.nix | 22 +- hosts/lifebook/default.nix | 2 +- modules/desktop/default.nix | 10 +- .../niri/{config.kdl => config-default.kdl} | 2 +- modules/wm/niri/config-lifebook.kdl | 411 ++++++++++++++++++ modules/wm/niri/home.nix | 4 - 6 files changed, 430 insertions(+), 21 deletions(-) rename modules/wm/niri/{config.kdl => config-default.kdl} (99%) create mode 100644 modules/wm/niri/config-lifebook.kdl diff --git a/hosts/home.nix b/hosts/home.nix index ec3f084..2ceabc7 100644 --- a/hosts/home.nix +++ b/hosts/home.nix @@ -86,17 +86,17 @@ # Flatpak vscodium - (vscode-with-extensions.override { - vscode = vscodium; - vscodeExtensions = with vscode-extensions; [ - vscodevim.vim - github.copilot - #ms-python.python - # ms-vscode.cpptools - catppuccin.catppuccin-vsc-icons - catppuccin.catppuccin-vsc - ]; - }) + #(vscode-with-extensions.override { + # vscode = vscodium; + # vscodeExtensions = with vscode-extensions; [ + # vscodevim.vim + # #github.copilot + # #ms-python.python + # # ms-vscode.cpptools + # catppuccin.catppuccin-vsc-icons + # catppuccin.catppuccin-vsc + # ]; + #}) sdkmanager ]; diff --git a/hosts/lifebook/default.nix b/hosts/lifebook/default.nix index 092a9d4..89a16ab 100644 --- a/hosts/lifebook/default.nix +++ b/hosts/lifebook/default.nix @@ -14,7 +14,7 @@ # ── Desktop module options ────────────────────────────────────────────── myDesktop.windowManager = "niri"; - myDesktop.niri.hotkeyVariant = "lifebook"; + myDesktop.niri.hostVariant = "lifebook"; myDesktop.cpu = "intel"; myDesktop.virtualisation.enable = true; diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index 939f92e..eae1eaa 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -104,10 +104,10 @@ in { nitrokey.enable = mkEnableOption "Nitrokey hardware security key support"; - niri.hotkeyVariant = mkOption { + niri.hostVariant = mkOption { type = types.enum ["default" "lifebook"]; default = "default"; - description = "Niri hotkey variant to deploy — selects binds/.kdl."; + description = "Niri Host variant to deploy — selects binds/.kdl. and config.kdl"; }; git.signingKey = mkOption { @@ -261,8 +261,10 @@ in { ../wm/niri/home.nix ]; - xdg.configFile."niri/binds.kdl".source = - ../wm/niri/binds/${cfg.niri.hotkeyVariant}.kdl; + xdg.configFile = { + "niri/binds.kdl".source = ../wm/niri/binds/${cfg.niri.hostVariant}.kdl; + "niri/config.kdl".source = ../wm/niri/config-${cfg.niri.hostVariant}.kdl; + }; services = { mako.enable = true; diff --git a/modules/wm/niri/config.kdl b/modules/wm/niri/config-default.kdl similarity index 99% rename from modules/wm/niri/config.kdl rename to modules/wm/niri/config-default.kdl index 2a86901..de71fa9 100644 --- a/modules/wm/niri/config.kdl +++ b/modules/wm/niri/config-default.kdl @@ -301,7 +301,7 @@ layout { // This line starts waybar, a commonly used bar for Wayland compositors. spawn-at-startup "noctalia-shell" spawn-at-startup "firefox" -spawn-at-startup "element-desktop" +//spawn-at-startup "element-desktop" spawn-at-startup "thunderbird" // To run a shell command (with variables, pipes, etc.), use spawn-sh-at-startup: diff --git a/modules/wm/niri/config-lifebook.kdl b/modules/wm/niri/config-lifebook.kdl new file mode 100644 index 0000000..2cdc6f9 --- /dev/null +++ b/modules/wm/niri/config-lifebook.kdl @@ -0,0 +1,411 @@ +// This config is in the KDL format: https://kdl.dev +// "/-" comments out the following node. +// Check the wiki for a full description of the configuration: +// https://yalter.github.io/niri/Configuration:-Introduction + +// Input device configuration. +// Find the full list of options on the wiki: +// https://yalter.github.io/niri/Configuration:-Input +input { + keyboard { + xkb { + // You can set rules, model, layout, variant and options. + // For more information, see xkeyboard-config(7). + + // For example: + layout "us,de" + options "grp:win_space_toggle" + + // If this section is empty, niri will fetch xkb settings + // from org.freedesktop.locale1. You can control these using + // localectl set-x11-keymap. + } + + // Enable numlock on startup, omitting this setting disables it. + //numlock + } + + // Next sections include libinput settings. + // Omitting settings disables them, or leaves them at their default values. + // All commented-out settings here are examples, not defaults. + touchpad { + // off + tap + // dwt + // dwtp + // drag false + // drag-lock + // natural-scroll + // accel-speed 0.2 + // accel-profile "flat" + scroll-method "two-finger" + // disabled-on-external-mouse + } + + mouse { + // off + // natural-scroll + // accel-speed 0.2 + // accel-profile "flat" + // scroll-method "no-scroll" + } + + trackpoint { + // off + // natural-scroll + // accel-speed 0.2 + // accel-profile "flat" + // scroll-method "on-button-down" + // scroll-button 273 + // scroll-button-lock + // middle-emulation + } + + touch { + map-to-output "eDP-1" + } + + // Uncomment this to make the mouse warp to the center of newly focused windows. + // warp-mouse-to-focus + + // Focus windows and outputs automatically when moving the mouse into them. + // Setting max-scroll-amount="0%" makes it work only on windows already fully on screen. + focus-follows-mouse max-scroll-amount="0%" + workspace-auto-back-and-forth +} + +// You can configure outputs by their name, which you can find +// by running `niri msg outputs` while inside a niri instance. +// The built-in laptop monitor is usually called "eDP-1". +// Find more information on the wiki: +// https://yalter.github.io/niri/Configuration:-Outputs +// Remember to uncomment the node by removing "/-"! +// Lenovo main +output "DP-2" { + mode "2560x1440" + scale 1.0 + transform "normal" + position x=0 y=250 + variable-refresh-rate +}; +// Eizo right +output "DP-3" { + mode "1920x1200" + scale 1.0 + transform "270" + position x=2560 y=0 +}; +output "eDP-1" { + // Uncomment this line to disable this output. + // off + + // Resolution and, optionally, refresh rate of the output. + // The format is "x" or "x@". + // If the refresh rate is omitted, niri will pick the highest refresh rate + // for the resolution. + // If the mode is omitted altogether or is invalid, niri will pick one automatically. + // Run `niri msg outputs` while inside a niri instance to list all outputs and their modes. + mode "1920x1080" + + // You can use integer or fractional scale, for example use 1.5 for 150% scale. + scale 1.2 + + // Transform allows to rotate the output counter-clockwise, valid values are: + // normal, 90, 180, 270, flipped, flipped-90, flipped-180 and flipped-270. + transform "normal" + + // Position of the output in the global coordinate space. + // This affects directional monitor actions like "focus-monitor-left", and cursor movement. + // The cursor can only move between directly adjacent outputs. + // Output scale and rotation has to be taken into account for positioning: + // outputs are sized in logical, or scaled, pixels. + // For example, a 3840×2160 output with scale 2.0 will have a logical size of 1920×1080, + // so to put another output directly adjacent to it on the right, set its x to 1920. + // If the position is unset or results in an overlap, the output is instead placed + // automatically. + position x=0 y=0 +} + +cursor { + xcursor-theme "Breeze_Hacked" + xcursor-size 24 + + hide-when-typing + hide-after-inactive-ms 1000 +} + +// Settings that influence how windows are positioned and sized. +// Find more information on the wiki: +// https://yalter.github.io/niri/Configuration:-Layout +layout { + // Set gaps around windows in logical pixels. + gaps 8 + + // When to center a column when changing focus, options are: + // - "never", default behavior, focusing an off-screen column will keep at the left + // or right edge of the screen. + // - "always", the focused column will always be centered. + // - "on-overflow", focusing a column will center it if it doesn't fit + // together with the previously focused column. + center-focused-column "never" + + // You can customize the widths that "switch-preset-column-width" (Mod+R) toggles between. + preset-column-widths { + // Proportion sets the width as a fraction of the output width, taking gaps into account. + // For example, you can perfectly fit four windows sized "proportion 0.25" on an output. + // The default preset widths are 1/3, 1/2 and 2/3 of the output. + proportion 0.33333 + proportion 0.5 + proportion 0.66667 + + // Fixed sets the width in logical pixels exactly. + // fixed 1920 + } + + // You can also customize the heights that "switch-preset-window-height" (Mod+Shift+R) toggles between. + preset-window-heights { + proportion 0.5 + proportion 1.0 + } + + // You can change the default width of the new windows. + //default-column-width { proportion 1.0; } + // If you leave the brackets empty, the windows themselves will decide their initial width. + default-column-width {} + + // By default focus ring and border are rendered as a solid background rectangle + // behind windows. That is, they will show up through semitransparent windows. + // This is because windows using client-side decorations can have an arbitrary shape. + // + // If you don't like that, you should uncomment `prefer-no-csd` below. + // Niri will draw focus ring and border *around* windows that agree to omit their + // client-side decorations. + // + // Alternatively, you can override it with a window rule called + // `draw-border-with-background`. + + // You can change how the focus ring looks. + focus-ring { + // Uncomment this line to disable the focus ring. + // off + + // How many logical pixels the ring extends out from the windows. + width 2 + + // Colors can be set in a variety of ways: + // - CSS named colors: "red" + // - RGB hex: "#rgb", "#rgba", "#rrggbb", "#rrggbbaa" + // - CSS-like notation: "rgb(255, 127, 0)", rgba(), hsl() and a few others. + + // Color of the ring on the active monitor. + active-color "#7fc8ff" + + // Color of the ring on inactive monitors. + // + // The focus ring only draws around the active window, so the only place + // where you can see its inactive-color is on other monitors. + inactive-color "#505050" + + // You can also use gradients. They take precedence over solid colors. + // Gradients are rendered the same as CSS linear-gradient(angle, from, to). + // The angle is the same as in linear-gradient, and is optional, + // defaulting to 180 (top-to-bottom gradient). + // You can use any CSS linear-gradient tool on the web to set these up. + // Changing the color space is also supported, check the wiki for more info. + // + // active-gradient from="#80c8ff" to="#c7ff7f" angle=45 + + // You can also color the gradient relative to the entire view + // of the workspace, rather than relative to just the window itself. + // To do that, set relative-to="workspace-view". + // + // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" + } + + // You can also add a border. It's similar to the focus ring, but always visible. + border { + // The settings are the same as for the focus ring. + // If you enable the border, you probably want to disable the focus ring. + off + + width 2 + active-color "#ffc87f" + inactive-color "#505050" + + // Color of the border around windows that request your attention. + urgent-color "#9b0000" + + // Gradients can use a few different interpolation color spaces. + // For example, this is a pastel rainbow gradient via in="oklch longer hue". + // + // active-gradient from="#e5989b" to="#ffb4a2" angle=45 relative-to="workspace-view" in="oklch longer hue" + + // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" + } + + // You can enable drop shadows for windows. + shadow { + // Uncomment the next line to enable shadows. + // on + + // By default, the shadow draws only around its window, and not behind it. + // Uncomment this setting to make the shadow draw behind its window. + // + // Note that niri has no way of knowing about the CSD window corner + // radius. It has to assume that windows have square corners, leading to + // shadow artifacts inside the CSD rounded corners. This setting fixes + // those artifacts. + // + // However, instead you may want to set prefer-no-csd and/or + // geometry-corner-radius. Then, niri will know the corner radius and + // draw the shadow correctly, without having to draw it behind the + // window. These will also remove client-side shadows if the window + // draws any. + // + // draw-behind-window true + + // You can change how shadows look. The values below are in logical + // pixels and match the CSS box-shadow properties. + + // Softness controls the shadow blur radius. + softness 30 + + // Spread expands the shadow. + spread 5 + + // Offset moves the shadow relative to the window. + offset x=0 y=5 + + // You can also change the shadow color and opacity. + color "#0007" + } + + // Struts shrink the area occupied by windows, similarly to layer-shell panels. + // You can think of them as a kind of outer gaps. They are set in logical pixels. + // Left and right struts will cause the next window to the side to always be visible. + // Top and bottom struts will simply add outer gaps in addition to the area occupied by + // layer-shell panels and regular gaps. + struts { + // left 64 + // right 64 + // top 6 + // bottom 64 + } +} + +// Add lines like this to spawn processes at startup. +// Note that running niri as a session supports xdg-desktop-autostart, +// which may be more convenient to use. +// See the binds section below for more spawn examples. + +// This line starts waybar, a commonly used bar for Wayland compositors. +spawn-at-startup "noctalia-shell" +//spawn-at-startup "firefox" +//spawn-at-startup "element-desktop" +//spawn-at-startup "thunderbird" + +// To run a shell command (with variables, pipes, etc.), use spawn-sh-at-startup: +// spawn-sh-at-startup "qs -c ~/source/qs/MyAwesomeShell" + +hotkey-overlay { + // Uncomment this line to disable the "Important Hotkeys" pop-up at startup. + skip-at-startup +} + +// Uncomment this line to ask the clients to omit their client-side decorations if possible. +// If the client will specifically ask for CSD, the request will be honored. +// Additionally, clients will be informed that they are tiled, removing some client-side rounded corners. +// This option will also fix border/focus ring drawing behind some semitransparent windows. +// After enabling or disabling this, you need to restart the apps for this to take effect. +prefer-no-csd + +// You can change the path where screenshots are saved. +// A ~ at the front will be expanded to the home directory. +// The path is formatted with strftime(3) to give you the screenshot date and time. +// screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png" + +// You can also set this to null to disable saving screenshots to disk. +screenshot-path null + +// Animation settings. +// The wiki explains how to configure individual animations: +// https://yalter.github.io/niri/Configuration:-Animations +animations { + // Uncomment to turn off all animations. + // off + + // Slow down all animations by this factor. Values below 1 speed them up instead. + // slowdown 3.0 +} + +// Window rules let you adjust behavior for individual windows. +// Find more information on the wiki: +// https://yalter.github.io/niri/Configuration:-Window-Rules + +// Work around WezTerm's initial configure bug +// by setting an empty default-column-width. +workspace "browser" { + open-on-output "DP-2" +} +workspace "chat" { + open-on-output "DP-3" +} +workspace "terminal" { +} + + +window-rule { + // This regular expression is intentionally made as specific as possible, + // since this is the default config, and we want no false positives. + // You can get away with just app-id="wezterm" if you want. + //match app-id=r#"^org\.wezfurlong\.wezterm$"# + match app-id="Alacritty" + match title="Firefox" + default-column-width { proportion 1.0; } +} + +window-rule { + match title="Firefox" + default-column-width { proportion 1.0; } + open-on-workspace "browser" +} +window-rule { + match app-id="Element" + match app-id="thunderbird" + default-column-width { proportion 1.0; } + open-on-workspace "chat" +} + + +// Open the Firefox picture-in-picture player as floating by default. +window-rule { + // This app-id regular expression will work for both: + // - host Firefox (app-id is "firefox") + // - Flatpak Firefox (app-id is "org.mozilla.firefox") + match app-id=r#"firefox$"# title="^Picture-in-Picture$" + match title="qalculate-qt" + match title="OpenSSH Askpass" + open-floating true +} + +// Example: block out two password managers from screen capture. +// (This example rule is commented out with a "/-" in front.) +/-window-rule { + match app-id=r#"^org\.keepassxc\.KeePassXC$"# + match app-id=r#"^org\.gnome\.World\.Secrets$"# + + block-out-from "screen-capture" + + // Use this instead if you want them visible on third-party screenshot tools. + // block-out-from "screencast" +} + +// Example: enable rounded corners for all windows. +// (This example rule is commented out with a "/-" in front.) +/-window-rule { + geometry-corner-radius 12 + clip-to-geometry true +} + +include "./binds.kdl" +include "./noctalia.kdl" diff --git a/modules/wm/niri/home.nix b/modules/wm/niri/home.nix index f55a3a1..743ca47 100644 --- a/modules/wm/niri/home.nix +++ b/modules/wm/niri/home.nix @@ -49,8 +49,4 @@ ]; }; }; - - xdg.configFile = { - "niri/config.kdl".source = ./config.kdl; - }; }