at 24.11-pre 2.1 kB view raw
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 = mkPackageOption pkgs "unclutter" { }; 17 18 keystroke = mkOption { 19 description = "Wait for a keystroke before hiding the cursor"; 20 type = types.bool; 21 default = false; 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 excluded = mkOption { 37 description = "Names of windows where unclutter should not apply"; 38 type = types.listOf types.str; 39 default = []; 40 example = [ "" ]; 41 }; 42 43 extraOptions = mkOption { 44 description = "More arguments to pass to the unclutter command"; 45 type = types.listOf types.str; 46 default = []; 47 example = [ "noevent" "grab" ]; 48 }; 49 }; 50 51 config = mkIf cfg.enable { 52 systemd.user.services.unclutter = { 53 description = "unclutter"; 54 wantedBy = [ "graphical-session.target" ]; 55 partOf = [ "graphical-session.target" ]; 56 serviceConfig.ExecStart = '' 57 ${cfg.package}/bin/unclutter \ 58 -idle ${toString cfg.timeout} \ 59 -jitter ${toString (cfg.threshold - 1)} \ 60 ${optionalString cfg.keystroke "-keystroke"} \ 61 ${concatMapStrings (x: " -"+x) cfg.extraOptions} \ 62 -not ${concatStringsSep " " cfg.excluded} \ 63 ''; 64 serviceConfig.PassEnvironment = "DISPLAY"; 65 serviceConfig.RestartSec = 3; 66 serviceConfig.Restart = "always"; 67 }; 68 }; 69 70 imports = [ 71 (mkRenamedOptionModule [ "services" "unclutter" "threeshold" ] 72 [ "services" "unclutter" "threshold" ]) 73 ]; 74 75 meta.maintainers = with lib.maintainers; [ rnhmjoj ]; 76 77}