2015-03-09 03:04:33 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2016-05-04 19:15:49 +00:00
|
|
|
|
2015-03-09 03:04:33 +00:00
|
|
|
with lib;
|
2016-05-04 19:15:49 +00:00
|
|
|
|
2015-03-09 03:04:33 +00:00
|
|
|
let cfg = config.services.unclutter;
|
2016-05-04 19:15:49 +00:00
|
|
|
|
2015-03-09 03:04:33 +00:00
|
|
|
in {
|
2016-05-04 19:15:49 +00:00
|
|
|
options.services.unclutter = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
description = "Enable unclutter to hide your mouse cursor when inactive";
|
2015-03-09 03:04:33 +00:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
2016-05-04 19:15:49 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.unclutter;
|
|
|
|
defaultText = "pkgs.unclutter";
|
|
|
|
description = "unclutter derivation to use.";
|
|
|
|
};
|
|
|
|
|
|
|
|
keystroke = mkOption {
|
|
|
|
description = "Wait for a keystroke before hiding the cursor";
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
timeout = mkOption {
|
|
|
|
description = "Number of seconds before the cursor is marked inactive";
|
|
|
|
type = types.int;
|
|
|
|
default = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
threeshold = mkOption {
|
|
|
|
description = "Minimum number of pixels considered cursor movement";
|
|
|
|
type = types.int;
|
|
|
|
default = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
excluded = mkOption {
|
|
|
|
description = "Names of windows where unclutter should not apply";
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
description = "More arguments to pass to the unclutter command";
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "noevent" "grab" ];
|
2015-03-09 03:04:33 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2016-05-04 19:15:49 +00:00
|
|
|
systemd.user.services.unclutter = {
|
2015-03-09 03:04:33 +00:00
|
|
|
description = "unclutter";
|
2016-05-04 19:15:49 +00:00
|
|
|
wantedBy = [ "default.target" ];
|
2015-03-09 03:04:33 +00:00
|
|
|
serviceConfig.ExecStart = ''
|
2016-05-04 19:15:49 +00:00
|
|
|
${cfg.package}/bin/unclutter \
|
|
|
|
-idle ${toString cfg.timeout} \
|
2017-04-02 18:23:12 +00:00
|
|
|
-display :${toString (
|
|
|
|
let display = config.services.xserver.display;
|
|
|
|
in if display != null then display else 0
|
|
|
|
)} \
|
2016-05-04 19:15:49 +00:00
|
|
|
-jitter ${toString (cfg.threeshold - 1)} \
|
|
|
|
${optionalString cfg.keystroke "-keystroke"} \
|
|
|
|
${concatMapStrings (x: " -"+x) cfg.extraOptions} \
|
|
|
|
-not ${concatStringsSep " " cfg.excluded} \
|
2015-03-09 03:04:33 +00:00
|
|
|
'';
|
2016-05-09 21:27:58 +00:00
|
|
|
serviceConfig.RestartSec = 3;
|
2015-03-09 03:04:33 +00:00
|
|
|
serviceConfig.Restart = "always";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|