at 16.09-beta 2.0 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 example = true; 15 }; 16 17 package = mkOption { 18 type = types.package; 19 default = pkgs.unclutter; 20 defaultText = "pkgs.unclutter"; 21 description = "unclutter derivation to use."; 22 }; 23 24 keystroke = mkOption { 25 description = "Wait for a keystroke before hiding the cursor"; 26 type = types.bool; 27 default = false; 28 }; 29 30 timeout = mkOption { 31 description = "Number of seconds before the cursor is marked inactive"; 32 type = types.int; 33 default = 1; 34 }; 35 36 threeshold = mkOption { 37 description = "Minimum number of pixels considered cursor movement"; 38 type = types.int; 39 default = 1; 40 }; 41 42 excluded = mkOption { 43 description = "Names of windows where unclutter should not apply"; 44 type = types.listOf types.str; 45 default = []; 46 example = [ "" ]; 47 }; 48 49 extraOptions = mkOption { 50 description = "More arguments to pass to the unclutter command"; 51 type = types.listOf types.str; 52 default = []; 53 example = [ "noevent" "grab" ]; 54 }; 55 }; 56 57 config = mkIf cfg.enable { 58 systemd.user.services.unclutter = { 59 description = "unclutter"; 60 wantedBy = [ "default.target" ]; 61 serviceConfig.ExecStart = '' 62 ${cfg.package}/bin/unclutter \ 63 -idle ${toString cfg.timeout} \ 64 -display :${toString config.services.xserver.display} \ 65 -jitter ${toString (cfg.threeshold - 1)} \ 66 ${optionalString cfg.keystroke "-keystroke"} \ 67 ${concatMapStrings (x: " -"+x) cfg.extraOptions} \ 68 -not ${concatStringsSep " " cfg.excluded} \ 69 ''; 70 serviceConfig.RestartSec = 3; 71 serviceConfig.Restart = "always"; 72 }; 73 }; 74}