1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let cfg = config.services.unclutter-xfixes;
6
7in {
8 options.services.unclutter-xfixes = {
9
10 enable = mkOption {
11 description = "Enable unclutter-xfixes to hide your mouse cursor when inactive.";
12 type = types.bool;
13 default = false;
14 };
15
16 package = mkOption {
17 description = "unclutter-xfixes derivation to use.";
18 type = types.package;
19 default = pkgs.unclutter-xfixes;
20 defaultText = "pkgs.unclutter-xfixes";
21 };
22
23 timeout = mkOption {
24 description = "Number of seconds before the cursor is marked inactive.";
25 type = types.int;
26 default = 1;
27 };
28
29 threshold = mkOption {
30 description = "Minimum number of pixels considered cursor movement.";
31 type = types.int;
32 default = 1;
33 };
34
35 extraOptions = mkOption {
36 description = "More arguments to pass to the unclutter-xfixes command.";
37 type = types.listOf types.str;
38 default = [];
39 example = [ "exclude-root" "ignore-scrolling" "fork" ];
40 };
41 };
42
43 config = mkIf cfg.enable {
44 systemd.user.services.unclutter-xfixes = {
45 description = "unclutter-xfixes";
46 wantedBy = [ "graphical-session.target" ];
47 partOf = [ "graphical-session.target" ];
48 serviceConfig.ExecStart = ''
49 ${cfg.package}/bin/unclutter \
50 --timeout ${toString cfg.timeout} \
51 --jitter ${toString (cfg.threshold - 1)} \
52 ${concatMapStrings (x: " --"+x) cfg.extraOptions} \
53 '';
54 serviceConfig.RestartSec = 3;
55 serviceConfig.Restart = "always";
56 };
57 };
58}