From 0b54e1877e0ac5d6c58654c54e29c664f42f7693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 7 May 2023 12:05:38 +0200 Subject: [PATCH] feat!: enable hibernation again --- modules/programs/hyprland/default.nix | 37 +++++++++++++++++++-------- modules/security/default.nix | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/modules/programs/hyprland/default.nix b/modules/programs/hyprland/default.nix index 0be3db8..f8db719 100644 --- a/modules/programs/hyprland/default.nix +++ b/modules/programs/hyprland/default.nix @@ -95,17 +95,32 @@ in command = "${pkgs.swaylock}/bin/swaylock -fF"; } ]; - timeouts = [ - { - timeout = 300; - command = "${hyprland}/bin/hyprctl dispatch dpms off"; - resumeCommand = "${hyprland}/bin/hyprctl dispatch dpms on"; - } - { - timeout = 310; - command = "${pkgs.systemd}/bin/loginctl lock-session"; - } - ]; + timeouts = + let + lockTimeout = 10; + in + [ + { + timeout = lockTimeout * 60 - 10; + command = "${pkgs.libnotify}/bin/notify-send 'Locking screen!'"; + } + { + timeout = lockTimeout * 60; + command = "${hyprland}/bin/hyprctl dispatch dpms off"; + resumeCommand = "${hyprland}/bin/hyprctl dispatch dpms on"; + } + { + timeout = lockTimeout * 60 + 10; + command = "${pkgs.systemd}/bin/loginctl lock-session"; + } + ] ++ optional + (!cfg.nvidiaSupport) # TODO https://github.com/hyprwm/Hyprland/issues/1728 + [ + { + timeout = 30 * 60; + command = "${pkgs.systemd}/bin/systemctl suspend-then-hibernate"; + } + ]; systemdTarget = "hyprland-session.target"; }; }; diff --git a/modules/security/default.nix b/modules/security/default.nix index 5b01fc2..6183dc5 100644 --- a/modules/security/default.nix +++ b/modules/security/default.nix @@ -4,7 +4,7 @@ }: { ## System security tweaks # Prevent replacing the running kernel w/o reboot - security.protectKernelImage = lib.mkDefault true; + # security.protectKernelImage = lib.mkDefault true; # NOTE disabled for now to enable hibernate # tmpfs = /tmp is mounted in ram. Doing so makes temp file management speedy # on ssd systems, and volatile! Because it's wiped on reboot.