home: wm: screen-lock: add 'notify.delay' setting
This commit is contained in:
parent
1b9b598662
commit
f5fcd2a7a6
|
@ -61,7 +61,26 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
notify = my.mkDisableOption "Notify when about to lock the screen";
|
notify = {
|
||||||
|
enable = my.mkDisableOption "Notify when about to lock the screen";
|
||||||
|
|
||||||
|
delay = mkOption {
|
||||||
|
type = with types;
|
||||||
|
addCheck int (x:
|
||||||
|
let
|
||||||
|
cfg = config.my.home.wm.screen-lock.notify;
|
||||||
|
cornerCfg = config.my.home.wm.screen-lock.cornerLock;
|
||||||
|
in
|
||||||
|
(cfg.enable && cornerCfg.enable) -> cornerCfg.delay >= x);
|
||||||
|
default = 5;
|
||||||
|
example = 15;
|
||||||
|
description = ''
|
||||||
|
How many seconds in advance should there be a notification.
|
||||||
|
This value must be at lesser than or equal to `cornerLock.delay`
|
||||||
|
when both options are enabled.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
timeout = mkOption {
|
timeout = mkOption {
|
||||||
type = types.ints.between 1 60;
|
type = types.ints.between 1 60;
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.my.home.wm.screen-lock;
|
cfg = config.my.home.wm.screen-lock;
|
||||||
|
|
||||||
|
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'"'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
@ -19,11 +27,11 @@ in
|
||||||
"${toString cfg.cornerLock.delay}"
|
"${toString cfg.cornerLock.delay}"
|
||||||
"-corners"
|
"-corners"
|
||||||
"+00-"
|
"+00-"
|
||||||
] ++ lib.optionals cfg.notify [
|
] ++ lib.optionals cfg.notify.enable [
|
||||||
"-notify"
|
"-notify"
|
||||||
"5"
|
"${toString cfg.notify.delay}"
|
||||||
"-notifier"
|
"-notifier"
|
||||||
''"${pkgs.libnotify}/bin/notify-send -u critical -t 5000 -- 'Locking in 5 seconds'"''
|
notficationCmd
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue