home: wm: add screen-lock

This commit is contained in:
Bruno BELANYI 2021-04-06 17:20:39 +00:00
parent 54a20058fb
commit 9f6c614c9f
2 changed files with 35 additions and 1 deletions

View file

@ -1,4 +1,4 @@
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
let
mkRelatedOption = description: relatedWMs:
let
@ -14,6 +14,7 @@ in
./i3.nix
./i3bar.nix
./rofi.nix
./screen-lock.nix
];
options.my.home.wm = with lib; {
@ -35,5 +36,23 @@ in
rofi = {
enable = mkRelatedOption "rofi menu" [ "i3" ];
};
screen-lock = {
enable = mkRelatedOption "automatic X screen locker" [ "i3" ];
command = mkOption {
type = types.str;
default = "${pkgs.i3lock}/bin/i3lock -n -c 000000";
example = "\${pkgs.i3lock}/bin/i3lock -n -i lock.png";
description = "Locker command to run";
};
timeout = mkOption {
type = types.ints.between 1 60;
default = 5;
example = 1;
description = "Inactive time interval to lock the screen automatically";
};
};
};
}

15
home/wm/screen-lock.nix Normal file
View file

@ -0,0 +1,15 @@
{ config, lib, ... }:
let
cfg = config.my.home.wm.screen-lock;
in
{
config = lib.mkIf cfg.enable {
services.screen-locker = {
enable = true;
inactiveInterval = cfg.timeout;
lockCmd = cfg.command;
};
};
}