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