Modules/Hyprland: Slight config cleanup

This commit is contained in:
2026-07-21 11:38:03 +02:00
parent 62358da6ca
commit 2b086cb17e
8 changed files with 115 additions and 110 deletions
+88 -60
View File
@@ -54,7 +54,7 @@ in
cursorSize = 24; cursorSize = 24;
cursorPackage = pkgs.bibata-cursors; cursorPackage = pkgs.bibata-cursors;
iconTheme = "Papirus"; iconTheme = "Papirus-Dark";
iconPackage = pkgs.papirus-icon-theme; iconPackage = pkgs.papirus-icon-theme;
scheme = "catppuccin-mocha"; scheme = "catppuccin-mocha";
@@ -85,58 +85,83 @@ in
keybindings = { keybindings = {
main-mod = "SUPER"; main-mod = "SUPER";
bindings = lib.mergeAttrsList [ bindings = let
{ sessionMenu = mylib.rofi.mkMenu {
# Applications prompt = "Session2";
"$mainMod, t" = ["exec, kitty"]; layers = [
"$mainMod, e" = ["exec, kitty --title=Yazi yazi"]; {
"$mainMod, n" = ["exec, neovide"]; "󰤂 Poweroff" = "poweroff";
# "$mainMod, r" = ["exec, kitty --title=Rmpc rmpc"]; "󰜉 Reboot" = "reboot";
"$mainMod CTRL, n" = ["exec, kitty --title=Navi navi"]; "󰌾 Lock" = "loginctl lock-session";
"$mainMod SHIFT, n" = ["exec, neovide ${config.paths.dotfiles}/navi/christoph.cheat"]; # " Reload Hyprpanel" = "systemctl --user restart hyprpanel.service";
"$mainMod SHIFT, f" = ["exec, neovide ${config.paths.dotfiles}/flake.nix"]; " Reload Hyprland" = "hyprctl reload";
# "ALT, tab" = ["exec, rofi -show window"]; " 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 # Screenshots
"$mainMod, p" = ["exec, hyprpicker --autocopy --format=hex"]; "$mainMod, p" = ["exec, hyprpicker --autocopy --format=hex"];
"$mainMod, s" = ["exec, grim -g \"$(slurp)\""]; "$mainMod, s" = ["exec, grim -g \"$(slurp)\""];
"$mainMod SHIFT, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"]; "$mainMod SHIFT, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"];
# Audio # Audio
", XF86AudioRaiseVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"]; ", XF86AudioRaiseVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"];
", XF86AudioLowerVolume" = ["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"]; ", XF86AudioPlay" = ["exec, playerctl play-pause"];
", XF86AudioPrev" = ["exec, playerctl previous"]; ", XF86AudioPrev" = ["exec, playerctl previous"];
", XF86AudioNext" = ["exec, playerctl next"]; ", XF86AudioNext" = ["exec, playerctl next"];
# Brightness # Brightness
", XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset gamma -10"]; ", XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset gamma -10"];
", XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset gamma +10"]; ", XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset gamma +10"];
"$mainMod, XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset temperature 5750"]; "$mainMod, XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset temperature 5750"];
"$mainMod, XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset identity"]; "$mainMod, XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset identity"];
"CTRL ALT, f" = let "CTRL ALT, f" = let
hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl"; hyprctl = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl";
grep = "${pkgs.gnugrep}/bin/grep"; grep = "${pkgs.gnugrep}/bin/grep";
awk = "${pkgs.gawk}/bin/gawk"; awk = "${pkgs.gawk}/bin/gawk";
notify = "${pkgs.libnotify}/bin/notify-send"; notify = "${pkgs.libnotify}/bin/notify-send";
toggleMouseFocus = pkgs.writeScriptBin "hypr-toggle-mouse-focus" '' toggleMouseFocus = pkgs.writeScriptBin "hypr-toggle-mouse-focus" ''
CURRENT=$(${hyprctl} getoption input:follow_mouse | ${grep} int | ${awk} -F' ' '{print $2}') CURRENT=$(${hyprctl} getoption input:follow_mouse | ${grep} int | ${awk} -F' ' '{print $2}')
if [[ "$CURRENT" == "1" ]]; then if [[ "$CURRENT" == "1" ]]; then
${hyprctl} keyword input:follow_mouse 0 ${hyprctl} keyword input:follow_mouse 0
${notify} "Disabled Mouse Focus!" ${notify} "Disabled Mouse Focus!"
else else
${hyprctl} keyword input:follow_mouse 1 ${hyprctl} keyword input:follow_mouse 1
${notify} "Enabled Mouse Focus!" ${notify} "Enabled Mouse Focus!"
fi fi
''; '';
in ["exec, ${toggleMouseFocus}/bin/hypr-toggle-mouse-focus"]; 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 = { ws-bindings = {
# "<Workspace>" = "<Key>"; # "<Workspace>" = "<Key>";
@@ -152,19 +177,18 @@ in
"10" = "0"; "10" = "0";
}; };
special-ws-bindings = { # special-ws-bindings = {
"ferdium" = "x"; # "ferdium" = "x";
"msty" = "z"; # "msty" = "z";
"btop" = "b"; # "btop" = "b";
"rmpc" = "r"; # "rmpc" = "r";
}; # };
}; };
autostart = { autostart = {
immediate = [ immediate = [
"kitty --hold fastfetch" "kitty --hold fastfetch"
# "zeal" # "zeal"
"nextcloud --background"
# "protonvpn-app" # "protonvpn-app"
# "kdeconnect-indicator" # started by services.kdeconnect.indicator # "kdeconnect-indicator" # started by services.kdeconnect.indicator
@@ -172,6 +196,7 @@ in
delayed = [ delayed = [
# "keepassxc" # The tray doesn't work when started too early # "keepassxc" # The tray doesn't work when started too early
"nextcloud --background"
]; ];
special-silent = { special-silent = {
@@ -190,15 +215,15 @@ in
workspacerules = { workspacerules = {
"1" = []; "1" = [];
"2" = ["neovide" "code-url-handler"]; "2" = ["neovide" "code-url-handler" "dev.zed.Zed" "code" "jetbrains-(.+)"];
"3" = ["obsidian" "Zotero"]; "3" = ["obsidian" "Zotero"];
"4" = ["firefox" "Google-chrome" "chromium-browser" "org.qutebrowser.qutebrowser"]; "4" = ["firefox" "Google-chrome" "chromium-browser" "org.qutebrowser.qutebrowser"];
"5" = ["steam"]; "5" = ["steam"];
"6" = ["steam_app_(.+)"]; "6" = ["steam_app_(.+)" "factorio"];
"7" = ["signal"]; "7" = ["signal"];
"8" = ["tidal-hifi"]; "8" = [];
"9" = ["discord"]; "9" = ["discord"];
"10" = ["python3"]; "10" = [];
}; };
floating = [ floating = [
@@ -209,9 +234,10 @@ in
} }
{class = "ffplay";} {class = "ffplay";}
{class = "Unity";} {class = "Unity";}
{class = "code-url-handler";}
]; ];
transparent-opacity = "0.75"; transparent-opacity = "0.85";
transparent = [ transparent = [
"kitty" "kitty"
@@ -297,9 +323,11 @@ in
# Enable wayland # Enable wayland
XDG_SESSION_TYPE = "wayland"; XDG_SESSION_TYPE = "wayland";
QT_QPA_PLATFORM = "wayland;xcb"; # QT_QPA_PLATFORM = "wayland;xcb";
QT_QPA_PLATFORM = "wayland";
NIXOS_OZONE_WL = "1"; 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 # Run SSH_ASKPASS as GUI, not TTY for Obsidian git
SSH_ASKPASS_REQUIRE = "prefer"; SSH_ASKPASS_REQUIRE = "prefer";
+1 -1
View File
@@ -36,7 +36,7 @@
y = 0; y = 0;
scale = 1; scale = 1;
bitdepth = 10; bitdepth = 10;
cm = "hdr"; cm = "auto"; # with render:cm_auto_hdr, we don't need hdr here
}; };
"DP-2" = { "DP-2" = {
+1
View File
@@ -44,6 +44,7 @@
inputs.nixvim.homeModules.nixvim inputs.nixvim.homeModules.nixvim
inputs.textfox.homeManagerModules.default inputs.textfox.homeManagerModules.default
inputs.walker.homeManagerModules.default inputs.walker.homeManagerModules.default
# inputs.stylix.homeModules.stylix
# inputs.direnv-instant.homeModules.direnv-instant # inputs.direnv-instant.homeModules.direnv-instant
# inputs.niri.homeModules.niri # Imported by system module # inputs.niri.homeModules.niri # Imported by system module
# inputs.noctalia.homeModules.default # inputs.noctalia.homeModules.default
+8 -1
View File
@@ -9,6 +9,8 @@ builtins.concatLists [
[ [
"hyprctl setcursor ${config.home.pointerCursor.name} ${builtins.toString config.home.pointerCursor.size}" "hyprctl setcursor ${config.home.pointerCursor.name} ${builtins.toString config.home.pointerCursor.size}"
"hyprsunset --identity" "hyprsunset --identity"
"waypaper --restore"
"fcitx5"
# HACK: Hyprland doesn't set the xwayland/x11 keymap correctly # 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" "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. # This is used for example when running systemd commands without root.
# "systemctl --user start hyprpolkitagent.service" # "systemctl --user start hyprpolkitagent.service"
# "${pkgs.kdePackages.polkit-kde-agent-1}/libexec/polkit-kde-authentication-agent-1" # "${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"
] ]
] ]
+7 -44
View File
@@ -24,11 +24,6 @@
in { in {
options.homemodules.hyprland = import ./options.nix {inherit lib mylib;}; 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 { config = lib.mkIf hyprland.enable {
assertions = [ assertions = [
{ {
@@ -78,45 +73,10 @@ in {
# Deps for Qt5 and Qt6 apps (e.g., Nextcloud) # Deps for Qt5 and Qt6 apps (e.g., Nextcloud)
qt5.qtwayland qt5.qtwayland
qt6.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 = { programs = {
@@ -131,12 +91,15 @@ in {
systemd.user.services.hypridle.Install.WantedBy = lib.mkForce ["hyprland-session.target"]; 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.After = lib.mkForce ["hyprland-session.target"];
systemd.user.services.hypridle.Unit.PartOf = 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 = { wayland.windowManager.hyprland = {
enable = true; enable = true;
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-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.enable = true; # Enable hyprland-session.target
systemd.variables = ["--all"]; # Import PATH into systemd systemd.variables = ["--all"]; # Import PATH into systemd
+5 -1
View File
@@ -137,8 +137,12 @@
hyprland.windowrules hyprland.windowrules
]; ];
render = {
cm_enabled = true;
cm_auto_hdr = true;
};
dwindle = { dwindle = {
pseudotile = true;
preserve_split = true; preserve_split = true;
}; };
+3 -1
View File
@@ -14,7 +14,7 @@
experimental-features = nix-command flakes pipe-operators experimental-features = nix-command flakes pipe-operators
''; '';
settings = { settings = rec {
trusted-users = ["root" username]; trusted-users = ["root" username];
auto-optimise-store = true; auto-optimise-store = true;
@@ -24,11 +24,13 @@
"https://cache.nixos.org" "https://cache.nixos.org"
"https://nix-community.cachix.org" "https://nix-community.cachix.org"
# "https://app.cachix.org/cache/nixos-rocm" # "https://app.cachix.org/cache/nixos-rocm"
"https://hyprland.cachix.org"
]; ];
trusted-public-keys = [ trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
# "nixos-rocm.cachix.org-1:VEpsf7pRIijjd8csKjFNBGzkBqOmw8H9PRmgAq14LnE=" # "nixos-rocm.cachix.org-1:VEpsf7pRIijjd8csKjFNBGzkBqOmw8H9PRmgAq14LnE="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
]; ];
}; };
+2 -2
View File
@@ -318,8 +318,8 @@ with mylib.networking; {
gpu-screen-recorder.enable = !headless; gpu-screen-recorder.enable = !headless;
hyprland = { hyprland = {
# enable = true; enable = false;
enable = !headless; # enable = !headless;
package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland; package = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.hyprland;
portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland; portalPackage = inputs.hyprland.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland;