fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge branch 'literalExpression' [#2371]4fa1ba72

master
1.6 KiB66 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let cfg = config.services.unclutter;
6
7in {
8  options.services.unclutter = {
9
10    enable = mkEnableOption "unclutter";
11
12    package = mkOption {
13      description = "unclutter derivation to use.";
14      type = types.package;
15      default = pkgs.unclutter-xfixes;
16      defaultText = literalExpression "pkgs.unclutter-xfixes";
17    };
18
19    timeout = mkOption {
20      description = "Number of seconds before the cursor is marked inactive.";
21      type = types.int;
22      default = 1;
23    };
24
25    threshold = mkOption {
26      description = "Minimum number of pixels considered cursor movement.";
27      type = types.int;
28      default = 1;
29    };
30
31    extraOptions = mkOption {
32      description = "More arguments to pass to the unclutter command.";
33      type = types.listOf types.str;
34      default = [ ];
35      example = [ "exclude-root" "ignore-scrolling" ];
36    };
37  };
38
39  config = mkIf cfg.enable {
40    assertions = [
41      (lib.hm.assertions.assertPlatform "services.unclutter" pkgs
42        lib.platforms.linux)
43    ];
44
45    systemd.user.services.unclutter = {
46      Unit = {
47        Description = "unclutter";
48        After = [ "graphical-session-pre.target" ];
49        PartOf = [ "graphical-session.target" ];
50      };
51
52      Service = {
53        ExecStart = ''
54          ${cfg.package}/bin/unclutter \
55            --timeout ${toString cfg.timeout} \
56            --jitter ${toString (cfg.threshold - 1)} \
57            ${concatMapStrings (x: " --${x}") cfg.extraOptions}
58        '';
59        RestartSec = 3;
60        Restart = "always";
61      };
62
63      Install = { WantedBy = [ "graphical-session.target" ]; };
64    };
65  };
66}