diff options
author | Katharina Fey <kookie@spacekookie.de> | 2019-10-05 12:06:29 +0000 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2019-10-05 12:42:50 +0000 |
commit | 1148b1d122bc03e9a3665856c9b7bb96bd4e3994 (patch) | |
tree | 1a9586de593790e236349d5caa0abdff7f3f6856 /home-manager/modules/services/screen-locker.nix | |
parent | 919d4e75699aa4ba456fd2d3d416a0522c9c7294 (diff) | |
parent | 8bddc1adab0f7a51476f819fa2197353e8e1d136 (diff) |
Add 'home-manager/' from commit '8bddc1adab0f7a51476f819fa2197353e8e1d136'
git-subtree-dir: home-manager
git-subtree-mainline: 919d4e75699aa4ba456fd2d3d416a0522c9c7294
git-subtree-split: 8bddc1adab0f7a51476f819fa2197353e8e1d136
Diffstat (limited to 'home-manager/modules/services/screen-locker.nix')
-rw-r--r-- | home-manager/modules/services/screen-locker.nix | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/home-manager/modules/services/screen-locker.nix b/home-manager/modules/services/screen-locker.nix new file mode 100644 index 00000000000..e3da14069bc --- /dev/null +++ b/home-manager/modules/services/screen-locker.nix @@ -0,0 +1,76 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.screen-locker; + +in { + + options.services.screen-locker = { + enable = mkEnableOption "screen locker for X session"; + + lockCmd = mkOption { + type = types.str; + description = "Locker command to run."; + example = "\${pkgs.i3lock}/bin/i3lock -n -c 000000"; + }; + + inactiveInterval = mkOption { + type = types.int; + default = 10; + description = '' + Inactive time interval in minutes after which session will be locked. + The minimum is 1 minute, and the maximum is 1 hour. + See <link xlink:href="https://linux.die.net/man/1/xautolock"/>. + ''; + }; + + xautolockExtraOptions = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra command-line arguments to pass to <command>xautolock</command>. + ''; + }; + + xssLockExtraOptions = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra command-line arguments to pass to <command>xss-lock</command>. + ''; + }; + + }; + + config = mkIf cfg.enable { + systemd.user.services.xautolock-session = { + Unit = { + Description = "xautolock, session locker service"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = concatStringsSep " " ([ + "${pkgs.xautolock}/bin/xautolock" + "-detectsleep" + "-time ${toString cfg.inactiveInterval}" + "-locker '${pkgs.systemd}/bin/loginctl lock-session $XDG_SESSION_ID'" + ] ++ cfg.xautolockExtraOptions); + }; + }; + + # xss-lock will run specified screen locker when the session is locked via loginctl + # can't be started as a systemd service, + # see https://bitbucket.org/raymonad/xss-lock/issues/13/allow-operation-as-systemd-user-unit + xsession.initExtra = "${pkgs.xss-lock}/bin/xss-lock ${concatStringsSep " " cfg.xssLockExtraOptions} -- ${cfg.lockCmd} &"; + }; + +} |