From 337168f47ef4d91479d859cbae80ff90965d794d Mon Sep 17 00:00:00 2001 From: Tad Fisher Date: Sat, 3 Mar 2018 22:53:10 -0800 Subject: [PATCH] unclutter: add module (cherry picked from commit 8fc8e158e2dcb4cd83dbf77011ce2a2633437dd5) --- modules/misc/news.nix | 7 ++++ modules/modules.nix | 1 + modules/services/unclutter.nix | 63 ++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 modules/services/unclutter.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 97db99cf9..a732f3ded 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -556,6 +556,13 @@ in A new module is available: 'programs.pidgin' ''; } + + { + time = "2018-03-04T06:54:26+00:00"; + message = '' + A new module is available: 'services.unclutter' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 3b5f705ab..de5749ff7 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -66,6 +66,7 @@ let ./services/taffybar.nix ./services/tahoe-lafs.nix ./services/udiskie.nix + ./services/unclutter.nix ./services/window-managers/i3.nix ./services/window-managers/xmonad.nix ./services/xscreensaver.nix diff --git a/modules/services/unclutter.nix b/modules/services/unclutter.nix new file mode 100644 index 000000000..26dca37ab --- /dev/null +++ b/modules/services/unclutter.nix @@ -0,0 +1,63 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.unclutter; + +in { + options.services.unclutter = { + + enable = mkEnableOption "unclutter"; + + package = mkOption { + description = "unclutter derivation to use."; + type = types.package; + default = pkgs.unclutter-xfixes; + defaultText = "pkgs.unclutter-xfixes"; + }; + + timeout = mkOption { + description = "Number of seconds before the cursor is marked inactive."; + type = types.int; + default = 1; + }; + + threshold = mkOption { + description = "Minimum number of pixels considered cursor movement."; + type = types.int; + default = 1; + }; + + extraOptions = mkOption { + description = "More arguments to pass to the unclutter command."; + type = types.listOf types.str; + default = [ ]; + example = [ "exclude-root" "ignore-scrolling" ]; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.unclutter = { + Unit = { + Description = "unclutter"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = '' + ${cfg.package}/bin/unclutter \ + --timeout ${toString cfg.timeout} \ + --jitter ${toString (cfg.threshold - 1)} \ + ${concatMapStrings (x: " --${x}") cfg.extraOptions} + ''; + RestartSec = 3; + Restart = "always"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +}