diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2017-05-19 07:09:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-19 07:09:10 +0100 |
commit | 2f22bbe1500dc7439c44daa3d996cc7ac5f3fd15 (patch) | |
tree | fd9c2393af1a456f5d14aedab0b46d8ea66da788 | |
parent | 380d6bbff137368d763295b5f0dc1ad42b80fbbb (diff) | |
parent | 9d1db321feecd7eee73a73f17a1dc187fac52a71 (diff) | |
download | nixlib-2f22bbe1500dc7439c44daa3d996cc7ac5f3fd15.tar nixlib-2f22bbe1500dc7439c44daa3d996cc7ac5f3fd15.tar.gz nixlib-2f22bbe1500dc7439c44daa3d996cc7ac5f3fd15.tar.bz2 nixlib-2f22bbe1500dc7439c44daa3d996cc7ac5f3fd15.tar.lz nixlib-2f22bbe1500dc7439c44daa3d996cc7ac5f3fd15.tar.xz nixlib-2f22bbe1500dc7439c44daa3d996cc7ac5f3fd15.tar.zst nixlib-2f22bbe1500dc7439c44daa3d996cc7ac5f3fd15.zip |
Merge pull request #25578 from Ma27/module/xautolock
services.xserver.xautolock: add module
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/x11/xautolock.nix | 72 |
2 files changed, 73 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 04f6e6c60e8b..930ac51f13b0 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -614,6 +614,7 @@ ./services/x11/window-managers/windowlab.nix ./services/x11/window-managers/wmii.nix ./services/x11/window-managers/xmonad.nix + ./services/x11/xautolock.nix ./services/x11/xbanish.nix ./services/x11/xfs.nix ./services/x11/xserver.nix diff --git a/nixos/modules/services/x11/xautolock.nix b/nixos/modules/services/x11/xautolock.nix new file mode 100644 index 000000000000..60ce9e6ed5c0 --- /dev/null +++ b/nixos/modules/services/x11/xautolock.nix @@ -0,0 +1,72 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.xserver.xautolock; +in + { + options = { + services.xserver.xautolock = { + enable = mkEnableOption "xautolock"; + enableNotifier = mkEnableOption "xautolock.notify" // { + description = '' + Whether to enable the notifier feature of xautolock. + This publishes a notification before the autolock. + ''; + }; + + time = mkOption { + default = 15; + type = types.int; + + description = '' + Idle time to wait until xautolock locks the computer. + ''; + }; + + locker = mkOption { + default = "xlock"; # default according to `man xautolock` + example = "i3lock -i /path/to/img"; + type = types.string; + + description = '' + The script to use when locking the computer. + ''; + }; + + notify = mkOption { + default = 10; + type = types.int; + + description = '' + Time (in seconds) before the actual lock when the notification about the pending lock should be published. + ''; + }; + + notifier = mkOption { + default = "notify-send 'Locking in 10 seconds'"; + type = types.string; + + description = '' + Notification script to be used to warn about the pending autolock. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ xautolock ]; + + services.xserver.displayManager.sessionCommands = with builtins; with pkgs; '' + ${xautolock}/bin/xautolock \ + ${concatStringsSep " \\\n" ([ + "-time ${toString(cfg.time)}" + "-locker ${cfg.locker}" + ] ++ optional cfg.enableNotifier (concatStringsSep " " [ + "-notify ${toString(cfg.notify)}" + "-notifier \"${cfg.notifier}\"" + ]))} & + ''; + }; + } |