nix-config/modules/home/wm/screen-lock/default.nix
Bruno BELANYI ba6d0ee918 home: wm: screen-lock: use 'writeShellApplication'
More robust implementation of the notifier.
2026-04-04 23:05:58 +01:00

38 lines
777 B
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.my.home.wm.screen-lock;
lockNotifier = pkgs.writeShellApplication {
name = "lock-notifier";
runtimeInputs = [
pkgs.libnotify
];
text = ''
duration=${toString cfg.notify.delay}
notify-send \
-u critical \
-t "$((duration * 1000))" -- \
"Locking in $duration seconds"
'';
};
in
{
config = lib.mkIf cfg.enable {
services.screen-locker = {
enable = true;
inactiveInterval = cfg.timeout;
lockCmd = cfg.command;
xautolock = {
extraOptions = lib.optionals cfg.notify.enable [
"-notify"
"${toString cfg.notify.delay}"
"-notifier"
(lib.getExe lockNotifier)
];
};
};
};
}