1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let cfg = config.services.unclutter;
6
7in {
8 options.services.unclutter = {
9
10 enable = mkOption {
11 description = "Enable unclutter to hide your mouse cursor when inactive";
12 type = types.bool;
13 default = false;
14 };
15
16 package = mkOption {
17 type = types.package;
18 default = pkgs.unclutter;
19 defaultText = "pkgs.unclutter";
20 description = "unclutter derivation to use.";
21 };
22
23 keystroke = mkOption {
24 description = "Wait for a keystroke before hiding the cursor";
25 type = types.bool;
26 default = false;
27 };
28
29 timeout = mkOption {
30 description = "Number of seconds before the cursor is marked inactive";
31 type = types.int;
32 default = 1;
33 };
34
35 threeshold = mkOption {
36 description = "Minimum number of pixels considered cursor movement";
37 type = types.int;
38 default = 1;
39 };
40
41 excluded = mkOption {
42 description = "Names of windows where unclutter should not apply";
43 type = types.listOf types.str;
44 default = [];
45 example = [ "" ];
46 };
47
48 extraOptions = mkOption {
49 description = "More arguments to pass to the unclutter command";
50 type = types.listOf types.str;
51 default = [];
52 example = [ "noevent" "grab" ];
53 };
54 };
55
56 config = mkIf cfg.enable {
57 systemd.user.services.unclutter = {
58 description = "unclutter";
59 wantedBy = [ "graphical-session.target" ];
60 partOf = [ "graphical-session.target" ];
61 serviceConfig.ExecStart = ''
62 ${cfg.package}/bin/unclutter \
63 -idle ${toString cfg.timeout} \
64 -jitter ${toString (cfg.threeshold - 1)} \
65 ${optionalString cfg.keystroke "-keystroke"} \
66 ${concatMapStrings (x: " -"+x) cfg.extraOptions} \
67 -not ${concatStringsSep " " cfg.excluded} \
68 '';
69 serviceConfig.PassEnvironment = "DISPLAY";
70 serviceConfig.RestartSec = 3;
71 serviceConfig.Restart = "always";
72 };
73 };
74}