home: wm: screen-lock: use 'writeShellApplication'

More robust implementation of the notifier.
This commit is contained in:
Bruno BELANYI 2026-04-04 16:09:33 +01:00
parent 8233f8e3d9
commit ba6d0ee918

View file

@ -2,13 +2,19 @@
let let
cfg = config.my.home.wm.screen-lock; cfg = config.my.home.wm.screen-lock;
notificationCmd = lockNotifier = pkgs.writeShellApplication {
let name = "lock-notifier";
duration = toString (cfg.notify.delay * 1000); runtimeInputs = [
notifyCmd = "${lib.getExe pkgs.libnotify} -u critical -t ${duration}"; pkgs.libnotify
in ];
# Needs to be surrounded by quotes for systemd to launch it correctly text = ''
''"${notifyCmd} -- 'Locking in ${toString cfg.notify.delay} seconds'"''; duration=${toString cfg.notify.delay}
notify-send \
-u critical \
-t "$((duration * 1000))" -- \
"Locking in $duration seconds"
'';
};
in in
{ {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -24,7 +30,7 @@ in
"-notify" "-notify"
"${toString cfg.notify.delay}" "${toString cfg.notify.delay}"
"-notifier" "-notifier"
notificationCmd (lib.getExe lockNotifier)
]; ];
}; };
}; };