feat(hyperlock): Added enabling hyperlock after sleep mode

This commit is contained in:
Black_Raven committed 2026-10-26 22:17:43 +03:00
1 parent 6d699a2cfa
commit ea2ddcd7d5
2 files changed
+123 -11

No files matched your search

+40 -1
View File
@@ -1,9 +1,37 @@
{ pkgs, lib, ... }:
{ config, pkgs, lib, ... }:
let
hyprLua = import ./hyprland/lua.nix { inherit lib; };
hyprlock = lib.getExe pkgs.hyprlock;
hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl";
loginctl = lib.getExe' pkgs.systemd "loginctl";
pidof = lib.getExe' pkgs.procps "pidof";
in {
wayland.windowManager.hyprland.settings.on = [ (hyprLua.onStart [ "hyprlock" ]) ];
# Hypridle listens to logind's PrepareForSleep signal: it locks the session
# before suspend and makes sure hyprlock is running (and the display is on)
# after resume.
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd = "${pidof} hyprlock >/dev/null || ${hyprlock}";
before_sleep_cmd = "${loginctl} lock-session";
after_sleep_cmd = "${pidof} hyprlock >/dev/null || ${hyprlock} & ${hyprctl} dispatch 'hl.dsp.dpms({action = \"on\"})'";
};
# Hypridle requires at least one listener, so keep a no-op timer that
# practically never fires. Screen locking is driven by sleep/resume only.
listener = [
{
timeout = 604800; # 7 days
on-timeout = "";
}
];
};
};
programs.hyprlock = let
image = pkgs.fetchurl {
name = "lock_background.png";
@@ -14,6 +42,17 @@ in {
enable = true;
settings = {
# Hyprlock's built-in fingerprint support watches logind's
# PrepareForSleep signal and re-arms itself after resume. PAM-based
# fingerprint auth (security.pam.services.hyprlock.fprintAuth) does not
# survive the fingerprint device being reset during suspend.
auth.fingerprint = {
enabled = true;
ready_message = "Scan fingerprint to unlock";
present_message = "Scanning...";
retry_delay = 250;
};
background = {
path = lib.mkForce "${image}";
blur_passes = 0;