From 159213cfe73d16e95baf43c871795ebd29c6ebbb Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sun, 13 Oct 2024 13:23:53 +0200 Subject: [PATCH] Hyprland: Update borders and enable hypridle + hyprlock --- home/modules/hyprland/default.nix | 188 ++++++++++++++++++++---------- system/default.nix | 1 - 2 files changed, 128 insertions(+), 61 deletions(-) diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix index 4ebcb382..a2e2f894 100644 --- a/home/modules/hyprland/default.nix +++ b/home/modules/hyprland/default.nix @@ -129,13 +129,17 @@ in { options.modules.hyprland = import ./options.nix {inherit lib mylib;}; config = lib.mkIf cfg.enable { + # Some assertion is not possible if HM is used standalone, + # because nixosConfig won't be available. assertions = [ { - # This assertion is not possible if HM is used standalone, - # because nixosConfig won't be available. assertion = nixosConfig.programs.hyprland.enable; message = "Can't enable Hyprland module with Hyprland disabled!"; } + { + assertion = builtins.hasAttr "hyprlock" nixosConfig.security.pam.services; + message = "Can't enable Hyprland module without Hyprlock PAM service!"; + } ]; gtk = { @@ -172,7 +176,8 @@ in { ]; file = { - ".config/hypr/keybindings.info".text = lib.pipe (lib.mergeAttrs cfg.keybindings.bindings always-bind) [ + ".config/hypr/keybindings.info".text = lib.pipe (cfg.keybindings.bindings + // always-bind) [ (builtins.mapAttrs mkBindsHelp) builtins.attrValues builtins.concatLists @@ -188,6 +193,119 @@ in { options.background = "ffffff"; }; }; + + hyprlock = { + enable = true; + + settings = { + general = { + disable_loading_bar = true; + grace = 0; + hide_cursor = true; + no_fade_in = false; + }; + + background = [ + { + path = "~/NixFlake/wallpapers/${cfg.theme}.png"; + blur_passes = 3; + blur_size = 8; + } + ]; + + input-field = [ + { + size = "200, 50"; + position = "0, -80"; + monitor = ""; + dots_center = true; + fade_on_empty = false; + font_color = "rgb(1E1E2E)"; + inner_color = "rgb(B4BEFE)"; + outer_color = "rgb(1E1E2E)"; + outline_thickness = 5; + placeholder_text = "Password..."; + shadow_passes = 2; + } + ]; + }; + }; + }; + + services = { + hyprpaper = { + enable = true; + + settings = { + preload = "~/NixFlake/wallpapers/${cfg.theme}.png"; + + wallpaper = lib.pipe cfg.monitors [ + builtins.attrNames + (builtins.map mkWallpaper) + ]; + }; + }; + + hypridle = { + enable = true; + + settings = { + general = { + # DPMS - Display Powermanagement Signaling. "On" means the monitor is on. + after_sleep_cmd = "hyprctl dispatch dpms on"; + ignore_dbus_inhibit = false; + lock_cmd = "hyprlock"; + }; + + listener = [ + { + timeout = 900; + on-timeout = "hyprlock"; + } + { + timeout = 1200; + on-timeout = "hyprctl dispatch dpms off"; + on-resume = "hyprctl dispatch dpms on"; + } + ]; + }; + }; + + # Notification service + dunst = { + enable = true; + + iconTheme.package = pkgs.papirus-icon-theme; + iconTheme.name = "Papirus"; + + settings = { + global = { + monitor = 1; + font = "JetBrains Nerd Font Mono 11"; + offset = "20x20"; + frame_color = "#1E66F5"; + frame_width = 2; + corner_radius = 5; + separator_color = "frame"; + }; + + urgency_low = { + background = "#EFF1F5"; + foreground = "#4C4F69"; + }; + + urgency_normal = { + background = "#EFF1F5"; + foreground = "#4C4F69"; + }; + + urgency_critical = { + background = "#EFF1F5"; + foreground = "#4C4F69"; + frame_color = "#FE640B"; + }; + }; + }; }; wayland.windowManager.hyprland = { @@ -200,11 +318,11 @@ in { general = { gaps_in = 5; - gaps_out = 20; + gaps_out = 10; border_size = 2; - "col.active_border" = "rgba(94E2D5FF)"; - "col.inactive_border" = "rgba(B4BEFEFF)"; + "col.active_border" = "rgb(B4BEFE)"; + "col.inactive_border" = "rgba(B4BEFE77)"; }; group = { @@ -214,8 +332,8 @@ in { gradients = false; }; - "col.border_active" = "rgba(94E2D5FF)"; - "col.border_inactive" = "rgba(B4BEFEFF)"; + "col.border_active" = "rgb(B4BEFE)"; + "col.border_inactive" = "rgba(B4BEFEAA)"; }; input = { @@ -245,7 +363,8 @@ in { builtins.concatLists ]; - bind = lib.pipe (lib.mergeAttrs cfg.keybindings.bindings always-bind) [ + bind = lib.pipe (cfg.keybindings.bindings + // always-bind) [ (builtins.mapAttrs mkBinds) builtins.attrValues builtins.concatLists @@ -330,56 +449,5 @@ in { }; }; }; - - services = { - hyprpaper = { - enable = true; - - settings = { - preload = "~/NixFlake/wallpapers/${cfg.theme}.png"; - - wallpaper = lib.pipe cfg.monitors [ - builtins.attrNames - (builtins.map mkWallpaper) - ]; - }; - }; - - # Notification service - dunst = { - enable = true; - - iconTheme.package = pkgs.papirus-icon-theme; - iconTheme.name = "Papirus"; - - settings = { - global = { - monitor = 1; - font = "JetBrains Nerd Font Mono 11"; - offset = "20x20"; - frame_color = "#1E66F5"; - frame_width = 2; - corner_radius = 5; - separator_color = "frame"; - }; - - urgency_low = { - background = "#EFF1F5"; - foreground = "#4C4F69"; - }; - - urgency_normal = { - background = "#EFF1F5"; - foreground = "#4C4F69"; - }; - - urgency_critical = { - background = "#EFF1F5"; - foreground = "#4C4F69"; - frame_color = "#FE640B"; - }; - }; - }; - }; }; } diff --git a/system/default.nix b/system/default.nix index 9fa6cea4..fa043ce7 100644 --- a/system/default.nix +++ b/system/default.nix @@ -398,7 +398,6 @@ with mylib.networking; { enable = true; # Startx replaces the displaymanager so default (lightdm) isn't used, start to shell - # Sadly using this with gnome-session doesn't really work displayManager.startx.enable = true; wacom.enable = true;