|
| 1 | +{ config, lib, pkgs, ... }: |
| 2 | + |
| 3 | +with lib; |
| 4 | + |
| 5 | +let cfg = config.services.unclutter-xfixes; |
| 6 | + |
| 7 | +in { |
| 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 | + example = true; |
| 15 | + }; |
| 16 | + |
| 17 | + package = mkOption { |
| 18 | + description = "unclutter-xfixes derivation to use."; |
| 19 | + type = types.package; |
| 20 | + default = pkgs.unclutter-xfixes; |
| 21 | + defaultText = "pkgs.unclutter-xfixes"; |
| 22 | + }; |
| 23 | + |
| 24 | + timeout = mkOption { |
| 25 | + description = "Number of seconds before the cursor is marked inactive."; |
| 26 | + type = types.int; |
| 27 | + default = 1; |
| 28 | + }; |
| 29 | + |
| 30 | + threshold = mkOption { |
| 31 | + description = "Minimum number of pixels considered cursor movement."; |
| 32 | + type = types.int; |
| 33 | + default = 1; |
| 34 | + }; |
| 35 | + |
| 36 | + extraOptions = mkOption { |
| 37 | + description = "More arguments to pass to the unclutter-xfixes command."; |
| 38 | + type = types.listOf types.str; |
| 39 | + default = []; |
| 40 | + example = [ "exclude-root" "ignore-scrolling" "fork" ]; |
| 41 | + }; |
| 42 | + }; |
| 43 | + |
| 44 | + config = mkIf cfg.enable { |
| 45 | + systemd.user.services.unclutter-xfixes = { |
| 46 | + description = "unclutter-xfixes"; |
| 47 | + wantedBy = [ "graphical.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 | +} |
0 commit comments