From 46b3a32b82f00a6bd73708af9feaf62e26d02244 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 6 Apr 2021 17:20:39 +0000 Subject: [PATCH] home: wm: add screen-lock --- home/wm/default.nix | 21 ++++++++++++++++++++- home/wm/screen-lock.nix | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 home/wm/screen-lock.nix diff --git a/home/wm/default.nix b/home/wm/default.nix index 5a50331..05c0e85 100644 --- a/home/wm/default.nix +++ b/home/wm/default.nix @@ -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"; + }; + }; }; } diff --git a/home/wm/screen-lock.nix b/home/wm/screen-lock.nix new file mode 100644 index 0000000..eca5895 --- /dev/null +++ b/home/wm/screen-lock.nix @@ -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; + }; + }; +}