2021-04-06 19:54:26 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-04-06 19:20:39 +02:00
|
|
|
let
|
|
|
|
cfg = config.my.home.wm.screen-lock;
|
2021-04-19 18:44:28 +02:00
|
|
|
|
|
|
|
notficationCmd =
|
|
|
|
let
|
|
|
|
duration = toString (cfg.notify.delay * 1000);
|
|
|
|
notifyCmd = "${pkgs.libnotify}/bin/notify-send -u critical -t ${duration}";
|
|
|
|
in
|
|
|
|
# Needs to be surrounded by quotes for systemd to launch it correctly
|
|
|
|
''"${notifyCmd} -- 'Locking in ${toString cfg.notify.delay} seconds'"'';
|
2021-04-06 19:20:39 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.screen-locker = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
inactiveInterval = cfg.timeout;
|
|
|
|
|
|
|
|
lockCmd = cfg.command;
|
2021-04-06 19:54:26 +02:00
|
|
|
|
2021-04-19 18:17:57 +02:00
|
|
|
xautolockExtraOptions = lib.optionals cfg.cornerLock.enable [
|
2021-04-06 19:54:26 +02:00
|
|
|
# Mouse corners: instant lock on upper-left, never lock on lower-right
|
|
|
|
"-cornerdelay"
|
2021-04-19 18:17:57 +02:00
|
|
|
"${toString cfg.cornerLock.delay}"
|
2021-04-06 19:54:26 +02:00
|
|
|
"-cornerredelay"
|
2021-04-19 18:17:57 +02:00
|
|
|
"${toString cfg.cornerLock.delay}"
|
2021-04-06 19:54:26 +02:00
|
|
|
"-corners"
|
|
|
|
"+00-"
|
2021-04-19 18:44:28 +02:00
|
|
|
] ++ lib.optionals cfg.notify.enable [
|
2021-04-06 19:54:26 +02:00
|
|
|
"-notify"
|
2021-04-19 18:44:28 +02:00
|
|
|
"${toString cfg.notify.delay}"
|
2021-04-06 19:54:26 +02:00
|
|
|
"-notifier"
|
2021-04-19 18:44:28 +02:00
|
|
|
notficationCmd
|
2021-04-06 19:54:26 +02:00
|
|
|
];
|
2021-04-06 19:20:39 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|