From 05f480acf5c5622d0680cc7404bf8c8b71c1c9cf Mon Sep 17 00:00:00 2001 From: Christoph Hollizeck Date: Wed, 29 Oct 2025 11:18:49 +0100 Subject: [PATCH] niri: switch from hyprland --- modules/desktop/niri.nix | 232 +++++++++++++++++++++++++++- modules/hosts/yggdrasil/default.nix | 4 +- 2 files changed, 228 insertions(+), 8 deletions(-) diff --git a/modules/desktop/niri.nix b/modules/desktop/niri.nix index c7fec4b..5870e07 100644 --- a/modules/desktop/niri.nix +++ b/modules/desktop/niri.nix @@ -12,10 +12,57 @@ package = inputs.niri-flake.packages.${pkgs.system}.niri-unstable; }; - environment.systemPackages = [ - pkgs.alacritty - pkgs.fuzzel + environment.systemPackages = with pkgs; [ + kitty + fuzzel + + inputs.niri-flake.packages.${pkgs.system}.xwayland-satellite-unstable + + wl-clipboard + xsel + + mako + waybar ]; + + xdg = { + autostart.enable = true; + portal = { + enable = true; + extraPortals = [ + pkgs.xdg-desktop-portal-gnome + pkgs.xdg-desktop-portal-gtk + ]; + xdgOpenUsePortal = true; + + config = { + common = { + default = [ "*" ]; + "org.freedesktop.impl.portal.Secret" = [ "gnome-keyring" ]; + }; + niri = { + default = [ + "gnome" + "gtk" + ]; + "org.freedesktop.impl.portal.FileChooser" = [ "gtk" ]; + "org.freedesktop.impl.portal.OpenURI" = [ "gtk" ]; + }; + }; + }; + }; + + environment.sessionVariables = { + NIXOS_OZONE_WL = "1"; # Hint electron apps to use wayland + ELECTRON_OZONE_PLATFORM_HINT = "auto"; + + XDG_SESSION_TYPE = "wayland"; + + QT_AUTO_SCREEN_SCALE_FACTOR = "1"; + QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; + QT_QPA_PLATFORM = "wayland;xcb"; + }; + }; homeManager.cholli = @@ -28,13 +75,23 @@ ... }: { + config = lib.mkIf (osConfig.networking.hostName == "yggdrasil" && osConfig.programs.niri.enable) { - config = lib.mkIf (osConfig.networking.hostName == "yggdrasil") { programs.niri.settings = { + prefer-no-csd = true; + input = { keyboard = { + xkb = { + layout = "us"; + rules = "escape:nocaps"; + }; numlock = true; }; + + touchpad = { + enable = false; + }; }; outputs."DP-1" = { @@ -49,6 +106,9 @@ height = 1080; }; transform.rotation = 90; + # layout = { + # default-column-width.proportion = 1.0; + # }; }; layout = { @@ -63,7 +123,6 @@ { proportion = 1. / 3.; } { proportion = 1. / 2.; } { proportion = 2. / 3.; } - ]; focus-ring = { @@ -81,8 +140,56 @@ screenshot-path = "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png"; - # block 1pass from screenshots and window capture + # TODO: block 1pass from screenshots and window capture + # TODO: move windows to workspaces where I expect them window-rules = [ + { + excludes = [ ]; + clip-to-geometry = true; + geometry-corner-radius = { + top-left = 15.0; + top-right = 15.0; + bottom-left = 15.0; + bottom-right = 15.0; + }; + } + { + matches = [ { is-window-cast-target = true; } ]; + + focus-ring = { + active.color = "#f38ba8"; + inactive.color = "#7d0d2d"; + }; + + border = { + inactive.color = "#7d0d2d"; + }; + + shadow = { + color = "#7d0d2d70"; + }; + + tab-indicator = { + active.color = "#f38ba8"; + inactive.color = "#7d0d2d"; + }; + } + { + matches = [ + { + app-id = "discord"; + } + { + app-id = "1Password"; + } + { + app-id = "steam"; + title = "Friends List.*"; + } + ]; + open-on-output = "HDMI-A-1"; + default-column-width.proportion = 1.0; + } ]; binds = @@ -98,11 +205,21 @@ }; }) workspaces ); + move-to-workspaces = builtins.listToAttrs ( + map (num: { + name = "Mod+Ctrl+${toString num}"; + value = { + action.move-window-to-workspace = num; + }; + }) workspaces + ); in lib.mkMerge [ { "Mod+Shift+Slash".action = actions.show-hotkey-overlay; + "Mod+Shift+E".action = actions.quit; + "Ctrl+Alt+Delete".action = actions.quit; "Mod+Return".action.spawn = "${lib.getExe pkgs.kitty}"; "Mod+D".action.spawn = "${lib.getExe pkgs.fuzzel}"; @@ -118,6 +235,99 @@ repeat = false; }; + "Mod+J" = { + action = actions.focus-window-or-workspace-down; + }; + "Mod+K" = { + action = actions.focus-window-or-workspace-up; + }; + "Mod+Ctrl+J" = { + action = actions.move-window-down-or-to-workspace-down; + }; + "Mod+Ctrl+K" = { + action = actions.move-window-up-or-to-workspace-up; + }; + "Mod+Down" = { + action = actions.focus-window-or-workspace-down; + }; + "Mod+Up" = { + action = actions.focus-window-or-workspace-up; + }; + "Mod+Ctrl+Down" = { + action = actions.move-window-down-or-to-workspace-down; + }; + "Mod+Ctrl+Up" = { + action = actions.move-window-up-or-to-workspace-up; + }; + + "Mod+H" = { + action = actions.focus-column-or-monitor-left; + }; + "Mod+L" = { + action = actions.focus-column-or-monitor-right; + }; + "Mod+Ctrl+H" = { + action = actions.move-column-left-or-to-monitor-left; + }; + "Mod+Ctrl+L" = { + action = actions.move-column-right-or-to-monitor-right; + }; + "Mod+Left" = { + action = actions.focus-column-or-monitor-left; + }; + "Mod+Right" = { + action = actions.focus-column-or-monitor-right; + }; + "Mod+Ctrl+Left" = { + action = actions.move-column-left-or-to-monitor-left; + }; + "Mod+Ctrl+Right" = { + action = actions.move-column-right-or-to-monitor-right; + }; + + "Mod+WheelScrollDown" = { + action = actions.focus-column-right; + }; + "Mod+WheelScrollUp" = { + action = actions.focus-column-left; + }; + "Mod+Shift+WheelScrollDown" = { + action = actions.focus-workspace-down; + cooldown-ms = 150; + }; + "Mod+Shift+WheelScrollUp" = { + action = actions.focus-workspace-up; + cooldown-ms = 150; + }; + + # Window Sizes + "Mod+BracketLeft".action = actions.consume-or-expel-window-left; + "Mod+BracketRight".action = actions.consume-or-expel-window-right; + "Mod+Comma".action = actions.consume-window-into-column; + "Mod+Period".action = actions.expel-window-from-column; + + "Mod+R".action = actions.switch-preset-column-width; + "Mod+Shift+R".action = actions.switch-preset-window-height; + "Mod+Ctrl+R".action = actions.reset-window-height; + "Mod+F".action = actions.fullscreen-window; + "Mod+Shift+F".action = actions.maximize-column; + "Mod+Ctrl+F".action = actions.expand-column-to-available-width; + + "Mod+C".action = actions.center-column; + "Mod+V".action = actions.toggle-window-floating; + + # Xwayland keyboard stuff + "Mod+Shift+C".action = actions.spawn [ + "sh" + "-c" + "env DISPLAY=:0 xsel -ob | wl-copy" + ]; + "Mod+Shift+V".action = actions.spawn [ + "sh" + "-c" + "wl-paste -n | env DISPLAY=:0 xsel -ib" + ]; + "XF86AudioRaiseVolume" = { action.spawn = [ "wpctl" @@ -156,8 +366,18 @@ }; } focus-workspaces + move-to-workspaces ]; + spawn-at-startup = [ + { argv = [ "waybar" ]; } + { argv = [ "zen-beta" ]; } + { argv = [ "steam" ]; } + { argv = [ "obsidian" ]; } + { argv = [ "discord" ]; } + { argv = [ "1password" ]; } + ]; + }; }; diff --git a/modules/hosts/yggdrasil/default.nix b/modules/hosts/yggdrasil/default.nix index 0894d92..51fcb24 100644 --- a/modules/hosts/yggdrasil/default.nix +++ b/modules/hosts/yggdrasil/default.nix @@ -24,6 +24,7 @@ in diebahn path-of-building + termscp ]; services.teamviewer.enable = true; @@ -53,7 +54,7 @@ in amdgpu # dektops - hyprland + # hyprland niri # apps @@ -99,6 +100,5 @@ in } ]; }; - }; }