From 2b086cb17e098874db678536a61ae50b555f2feb Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Tue, 21 Jul 2026 11:37:33 +0200 Subject: [PATCH] Modules/Hyprland: Slight config cleanup --- home/christoph/default.nix | 148 ++++++++++++++---------- home/christoph/nixinator/default.nix | 2 +- home/homemodules/default.nix | 1 + home/homemodules/hyprland/autostart.nix | 9 +- home/homemodules/hyprland/default.nix | 51 ++------ home/homemodules/hyprland/settings.nix | 6 +- lib/nixos.nix | 4 +- system/default.nix | 4 +- 8 files changed, 115 insertions(+), 110 deletions(-) diff --git a/home/christoph/default.nix b/home/christoph/default.nix index 1b70d84..72adaae 100644 --- a/home/christoph/default.nix +++ b/home/christoph/default.nix @@ -54,7 +54,7 @@ in cursorSize = 24; cursorPackage = pkgs.bibata-cursors; - iconTheme = "Papirus"; + iconTheme = "Papirus-Dark"; iconPackage = pkgs.papirus-icon-theme; scheme = "catppuccin-mocha"; @@ -85,58 +85,83 @@ in keybindings = { main-mod = "SUPER"; - bindings = lib.mergeAttrsList [ - { - # Applications - "$mainMod, t" = ["exec, kitty"]; - "$mainMod, e" = ["exec, kitty --title=Yazi yazi"]; - "$mainMod, n" = ["exec, neovide"]; - # "$mainMod, r" = ["exec, kitty --title=Rmpc rmpc"]; - "$mainMod CTRL, n" = ["exec, kitty --title=Navi navi"]; - "$mainMod SHIFT, n" = ["exec, neovide ${config.paths.dotfiles}/navi/christoph.cheat"]; - "$mainMod SHIFT, f" = ["exec, neovide ${config.paths.dotfiles}/flake.nix"]; - # "ALT, tab" = ["exec, rofi -show window"]; + bindings = let + sessionMenu = mylib.rofi.mkMenu { + prompt = "Session2"; + layers = [ + { + "󰤂 Poweroff" = "poweroff"; + "󰜉 Reboot" = "reboot"; + "󰌾 Lock" = "loginctl lock-session"; + # " Reload Hyprpanel" = "systemctl --user restart hyprpanel.service"; + " Reload Hyprland" = "hyprctl reload"; + " Exit Hyprland" = "hyprctl dispatch exit"; + # " Exit Niri" = "niri msg action quit"; + } + ]; + prompts = ["Select Session Action"]; + rofiCmd = "walker -d"; + }; + in + lib.mergeAttrsList [ + { + "$mainMod SHIFT, a" = ["exec, walker -m providerlist"]; + "$mainMod, a" = ["exec, walker -m desktopapplications"]; + "$mainMod, c" = ["exec, walker -m clipboard"]; + "$mainMod, Escape" = ["exec, ${sessionMenu}/bin/rofi-menu-Session2"]; + "$mainMod CTRL, w" = ["exec, waypaper"]; + } + { + # Applications + "$mainMod, t" = ["exec, kitty"]; + "$mainMod, e" = ["exec, kitty --title=Yazi yazi"]; + "$mainMod, n" = ["exec, neovide"]; + # "$mainMod, r" = ["exec, kitty --title=Rmpc rmpc"]; + "$mainMod CTRL, n" = ["exec, kitty --title=Navi navi"]; + "$mainMod SHIFT, n" = ["exec, neovide ${config.paths.dotfiles}/navi/christoph.cheat"]; + "$mainMod SHIFT, f" = ["exec, neovide ${config.paths.dotfiles}/flake.nix"]; + # "ALT, tab" = ["exec, rofi -show window"]; - # Screenshots - "$mainMod, p" = ["exec, hyprpicker --autocopy --format=hex"]; - "$mainMod, s" = ["exec, grim -g \"$(slurp)\""]; - "$mainMod SHIFT, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"]; + # Screenshots + "$mainMod, p" = ["exec, hyprpicker --autocopy --format=hex"]; + "$mainMod, s" = ["exec, grim -g \"$(slurp)\""]; + "$mainMod SHIFT, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"]; - # Audio - ", XF86AudioRaiseVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"]; - ", XF86AudioLowerVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-"]; - ", XF86AudioPlay" = ["exec, playerctl play-pause"]; - ", XF86AudioPrev" = ["exec, playerctl previous"]; - ", XF86AudioNext" = ["exec, playerctl next"]; + # Audio + ", XF86AudioRaiseVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"]; + ", XF86AudioLowerVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-"]; + ", XF86AudioPlay" = ["exec, playerctl play-pause"]; + ", XF86AudioPrev" = ["exec, playerctl previous"]; + ", XF86AudioNext" = ["exec, playerctl next"]; - # Brightness - ", XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset gamma -10"]; - ", XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset gamma +10"]; - "$mainMod, XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset temperature 5750"]; - "$mainMod, XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset identity"]; + # Brightness + ", XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset gamma -10"]; + ", XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset gamma +10"]; + "$mainMod, XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset temperature 5750"]; + "$mainMod, XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset identity"]; - "CTRL ALT, f" = let - hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl"; - grep = "${pkgs.gnugrep}/bin/grep"; - awk = "${pkgs.gawk}/bin/gawk"; - notify = "${pkgs.libnotify}/bin/notify-send"; + "CTRL ALT, f" = let + hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl"; + grep = "${pkgs.gnugrep}/bin/grep"; + awk = "${pkgs.gawk}/bin/gawk"; + notify = "${pkgs.libnotify}/bin/notify-send"; - toggleMouseFocus = pkgs.writeScriptBin "hypr-toggle-mouse-focus" '' - CURRENT=$(${hyprctl} getoption input:follow_mouse | ${grep} int | ${awk} -F' ' '{print $2}') + toggleMouseFocus = pkgs.writeScriptBin "hypr-toggle-mouse-focus" '' + CURRENT=$(${hyprctl} getoption input:follow_mouse | ${grep} int | ${awk} -F' ' '{print $2}') - if [[ "$CURRENT" == "1" ]]; then - ${hyprctl} keyword input:follow_mouse 0 - ${notify} "Disabled Mouse Focus!" - else - ${hyprctl} keyword input:follow_mouse 1 - ${notify} "Enabled Mouse Focus!" - fi - ''; - in ["exec, ${toggleMouseFocus}/bin/hypr-toggle-mouse-focus"]; + if [[ "$CURRENT" == "1" ]]; then + ${hyprctl} keyword input:follow_mouse 0 + ${notify} "Disabled Mouse Focus!" + else + ${hyprctl} keyword input:follow_mouse 1 + ${notify} "Enabled Mouse Focus!" + fi + ''; + in ["exec, ${toggleMouseFocus}/bin/hypr-toggle-mouse-focus"]; - # "CTRL ALT, t" = ["exec, bash -c 'systemctl --user restart hyprpanel.service'"]; - } - ]; + # "CTRL ALT, t" = ["exec, bash -c 'systemctl --user restart hyprpanel.service'"]; + } + ]; ws-bindings = { # "" = ""; @@ -152,19 +177,18 @@ in "10" = "0"; }; - special-ws-bindings = { - "ferdium" = "x"; - "msty" = "z"; - "btop" = "b"; - "rmpc" = "r"; - }; + # special-ws-bindings = { + # "ferdium" = "x"; + # "msty" = "z"; + # "btop" = "b"; + # "rmpc" = "r"; + # }; }; autostart = { immediate = [ "kitty --hold fastfetch" # "zeal" - "nextcloud --background" # "protonvpn-app" # "kdeconnect-indicator" # started by services.kdeconnect.indicator @@ -172,6 +196,7 @@ in delayed = [ # "keepassxc" # The tray doesn't work when started too early + "nextcloud --background" ]; special-silent = { @@ -190,15 +215,15 @@ in workspacerules = { "1" = []; - "2" = ["neovide" "code-url-handler"]; + "2" = ["neovide" "code-url-handler" "dev.zed.Zed" "code" "jetbrains-(.+)"]; "3" = ["obsidian" "Zotero"]; "4" = ["firefox" "Google-chrome" "chromium-browser" "org.qutebrowser.qutebrowser"]; "5" = ["steam"]; - "6" = ["steam_app_(.+)"]; + "6" = ["steam_app_(.+)" "factorio"]; "7" = ["signal"]; - "8" = ["tidal-hifi"]; + "8" = []; "9" = ["discord"]; - "10" = ["python3"]; + "10" = []; }; floating = [ @@ -209,9 +234,10 @@ in } {class = "ffplay";} {class = "Unity";} + {class = "code-url-handler";} ]; - transparent-opacity = "0.75"; + transparent-opacity = "0.85"; transparent = [ "kitty" @@ -297,9 +323,11 @@ in # Enable wayland XDG_SESSION_TYPE = "wayland"; - QT_QPA_PLATFORM = "wayland;xcb"; + # QT_QPA_PLATFORM = "wayland;xcb"; + QT_QPA_PLATFORM = "wayland"; NIXOS_OZONE_WL = "1"; - # SDL_VIDEODRIVER = "wayland"; # Leave unset as gamescope uses xwayland + # ELECTRON_OZONE_PLATFORM_HINT = "auto"; + SDL_VIDEODRIVER = "wayland"; # Leave unset as gamescope uses xwayland # Run SSH_ASKPASS as GUI, not TTY for Obsidian git SSH_ASKPASS_REQUIRE = "prefer"; diff --git a/home/christoph/nixinator/default.nix b/home/christoph/nixinator/default.nix index 2843fe3..5f31e5d 100644 --- a/home/christoph/nixinator/default.nix +++ b/home/christoph/nixinator/default.nix @@ -36,7 +36,7 @@ y = 0; scale = 1; bitdepth = 10; - cm = "hdr"; + cm = "auto"; # with render:cm_auto_hdr, we don't need hdr here }; "DP-2" = { diff --git a/home/homemodules/default.nix b/home/homemodules/default.nix index 150dba6..4a29b1b 100644 --- a/home/homemodules/default.nix +++ b/home/homemodules/default.nix @@ -44,6 +44,7 @@ inputs.nixvim.homeModules.nixvim inputs.textfox.homeManagerModules.default inputs.walker.homeManagerModules.default + # inputs.stylix.homeModules.stylix # inputs.direnv-instant.homeModules.direnv-instant # inputs.niri.homeModules.niri # Imported by system module # inputs.noctalia.homeModules.default diff --git a/home/homemodules/hyprland/autostart.nix b/home/homemodules/hyprland/autostart.nix index 9981f7c..b511254 100644 --- a/home/homemodules/hyprland/autostart.nix +++ b/home/homemodules/hyprland/autostart.nix @@ -9,6 +9,8 @@ builtins.concatLists [ [ "hyprctl setcursor ${config.home.pointerCursor.name} ${builtins.toString config.home.pointerCursor.size}" "hyprsunset --identity" + "waypaper --restore" + "fcitx5" # HACK: Hyprland doesn't set the xwayland/x11 keymap correctly "setxkbmap -layout ${hyprland.keyboard.layout} -variant ${hyprland.keyboard.variant} -option ${hyprland.keyboard.option} -model pc104" @@ -20,6 +22,11 @@ builtins.concatLists [ # This is used for example when running systemd commands without root. # "systemctl --user start hyprpolkitagent.service" # "${pkgs.kdePackages.polkit-kde-agent-1}/libexec/polkit-kde-authentication-agent-1" - "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1" + + # TODO: This is started by niri already (extract to module so niri/hyprland can both use it) + # "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1" + + # TODO: This is started by niri already (extract to module so niri/hyprland can both use it) + "dunst" ] ] diff --git a/home/homemodules/hyprland/default.nix b/home/homemodules/hyprland/default.nix index a65c461..0683d45 100644 --- a/home/homemodules/hyprland/default.nix +++ b/home/homemodules/hyprland/default.nix @@ -24,11 +24,6 @@ in { options.homemodules.hyprland = import ./options.nix {inherit lib mylib;}; - # TODO: Extract common niri/hyprland stuff to modules (e.g., dunst), so no configs are duplicated - # TODO: Remove unnecessary bullshit - # TODO: Switch to lua config - # TODO: Synchronize with niri mappings - config = lib.mkIf hyprland.enable { assertions = [ { @@ -78,45 +73,10 @@ in { # Deps for Qt5 and Qt6 apps (e.g., Nextcloud) qt5.qtwayland qt6.qtwayland + + # xwayland + # wayland-protocols ]; - - file = { - ".config/hypr/keybindings.info".text = let - fixupHomeDir = key: - builtins.replaceStrings ["/home/${username}"] ["~"] key; - - fixupNixStore = key: let - # The pattern has to match the entire string, otherwise it won't work - matches = builtins.match ".*/nix/store/(.*)/.*" key; - in - if (matches == null) - then key - else builtins.replaceStrings matches ["..."] key; - - fixupNoMod = key: - builtins.replaceStrings ["<-"] ["<"] key; - - mkBindHelpKey = key: - builtins.replaceStrings ["$mainMod" " " ","] ["${hyprland.keybindings.main-mod}" "-" ""] key; - - mkBindHelpAction = action: - builtins.replaceStrings [","] [""] action; - - mkBindHelp = key: action: "<${mkBindHelpKey key}>: ${mkBindHelpAction action}"; - - mkBindsHelp = key: actions: - actions - |> builtins.map (mkBindHelp key) - |> builtins.map fixupNoMod - |> builtins.map fixupNixStore - |> builtins.map fixupHomeDir; - in - (hyprland.keybindings.bindings // always-bind) - |> builtins.mapAttrs mkBindsHelp - |> builtins.attrValues - |> builtins.concatLists - |> builtins.concatStringsSep "\n"; - }; }; programs = { @@ -131,12 +91,15 @@ in { systemd.user.services.hypridle.Install.WantedBy = lib.mkForce ["hyprland-session.target"]; systemd.user.services.hypridle.Unit.After = lib.mkForce ["hyprland-session.target"]; systemd.user.services.hypridle.Unit.PartOf = lib.mkForce ["hyprland-session.target"]; + systemd.user.services.elephant.Install.WantedBy = lib.mkForce ["hyprland-session.target" "graphical-session.target"]; + systemd.user.services.elephant.Unit.After = lib.mkForce ["hyprland-session.target" "graphical-session.target"]; + systemd.user.services.elephant.Unit.PartOf = lib.mkForce ["hyprland-session.target" "graphical-session.target"]; wayland.windowManager.hyprland = { enable = true; package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland; - configType = "hyprlang"; # TODO: lua + configType = "hyprlang"; systemd.enable = true; # Enable hyprland-session.target systemd.variables = ["--all"]; # Import PATH into systemd diff --git a/home/homemodules/hyprland/settings.nix b/home/homemodules/hyprland/settings.nix index 9bc1d48..8404c9c 100644 --- a/home/homemodules/hyprland/settings.nix +++ b/home/homemodules/hyprland/settings.nix @@ -137,8 +137,12 @@ hyprland.windowrules ]; + render = { + cm_enabled = true; + cm_auto_hdr = true; + }; + dwindle = { - pseudotile = true; preserve_split = true; }; diff --git a/lib/nixos.nix b/lib/nixos.nix index 125f15c..e44e361 100644 --- a/lib/nixos.nix +++ b/lib/nixos.nix @@ -14,7 +14,7 @@ experimental-features = nix-command flakes pipe-operators ''; - settings = { + settings = rec { trusted-users = ["root" username]; auto-optimise-store = true; @@ -24,11 +24,13 @@ "https://cache.nixos.org" "https://nix-community.cachix.org" # "https://app.cachix.org/cache/nixos-rocm" + "https://hyprland.cachix.org" ]; trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" # "nixos-rocm.cachix.org-1:VEpsf7pRIijjd8csKjFNBGzkBqOmw8H9PRmgAq14LnE=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" ]; }; diff --git a/system/default.nix b/system/default.nix index 8d6b2de..de4da2e 100644 --- a/system/default.nix +++ b/system/default.nix @@ -318,8 +318,8 @@ with mylib.networking; { gpu-screen-recorder.enable = !headless; hyprland = { - # enable = true; - enable = !headless; + enable = false; + # enable = !headless; package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;