home: wm: add screen-lock

This commit is contained in:
Bruno BELANYI 2021-04-06 17:20:39 +00:00
parent 79d92178b5
commit 46b3a32b82
2 changed files with 35 additions and 1 deletions

View file

@ -1,4 +1,4 @@
{ config, lib, ... }: { config, lib, pkgs, ... }:
let let
mkRelatedOption = description: relatedWMs: mkRelatedOption = description: relatedWMs:
let let
@ -14,6 +14,7 @@ in
./i3.nix ./i3.nix
./i3bar.nix ./i3bar.nix
./rofi.nix ./rofi.nix
./screen-lock.nix
]; ];
options.my.home.wm = with lib; { options.my.home.wm = with lib; {
@ -35,5 +36,23 @@ in
rofi = { rofi = {
enable = mkRelatedOption "rofi menu" [ "i3" ]; 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;
};
};
}