2015-03-09 03:04:33 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2016-05-04 20:15:49 +01:00
|
|
|
|
2015-03-09 03:04:33 +00:00
|
|
|
with lib;
|
2016-05-04 20:15:49 +01:00
|
|
|
|
2015-03-09 03:04:33 +00:00
|
|
|
let cfg = config.services.unclutter;
|
2016-05-04 20:15:49 +01:00
|
|
|
|
2015-03-09 03:04:33 +00:00
|
|
|
in {
|
2016-05-04 20:15:49 +01:00
|
|
|
options.services.unclutter = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "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 20:15:49 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.unclutter;
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "pkgs.unclutter";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "unclutter derivation to use.";
|
2016-05-04 20:15:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
keystroke = mkOption {
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Wait for a keystroke before hiding the cursor";
|
2016-05-04 20:15:49 +01:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
timeout = mkOption {
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Number of seconds before the cursor is marked inactive";
|
2016-05-04 20:15:49 +01:00
|
|
|
type = types.int;
|
|
|
|
default = 1;
|
|
|
|
};
|
|
|
|
|
2020-01-19 09:09:12 +00:00
|
|
|
threshold = mkOption {
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Minimum number of pixels considered cursor movement";
|
2016-05-04 20:15:49 +01:00
|
|
|
type = types.int;
|
|
|
|
default = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
excluded = mkOption {
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Names of windows where unclutter should not apply";
|
2016-05-04 20:15:49 +01:00
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
extraOptions = mkOption {
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "More arguments to pass to the unclutter command";
|
2016-05-04 20:15:49 +01:00
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "noevent" "grab" ];
|
2015-03-09 03:04:33 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2016-05-04 20:15:49 +01:00
|
|
|
systemd.user.services.unclutter = {
|
2015-03-09 03:04:33 +00:00
|
|
|
description = "unclutter";
|
2017-05-25 18:33:13 +01:00
|
|
|
wantedBy = [ "graphical-session.target" ];
|
|
|
|
partOf = [ "graphical-session.target" ];
|
2015-03-09 03:04:33 +00:00
|
|
|
serviceConfig.ExecStart = ''
|
2016-05-04 20:15:49 +01:00
|
|
|
${cfg.package}/bin/unclutter \
|
|
|
|
-idle ${toString cfg.timeout} \
|
2020-02-14 00:28:03 +00:00
|
|
|
-jitter ${toString (cfg.threshold - 1)} \
|
2016-05-04 20:15:49 +01:00
|
|
|
${optionalString cfg.keystroke "-keystroke"} \
|
|
|
|
${concatMapStrings (x: " -"+x) cfg.extraOptions} \
|
|
|
|
-not ${concatStringsSep " " cfg.excluded} \
|
2015-03-09 03:04:33 +00:00
|
|
|
'';
|
2017-05-25 18:33:13 +01:00
|
|
|
serviceConfig.PassEnvironment = "DISPLAY";
|
2016-05-09 22:27:58 +01:00
|
|
|
serviceConfig.RestartSec = 3;
|
2015-03-09 03:04:33 +00:00
|
|
|
serviceConfig.Restart = "always";
|
|
|
|
};
|
|
|
|
};
|
2019-12-04 16:07:45 +00:00
|
|
|
|
2020-01-19 09:09:12 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "unclutter" "threeshold" ]
|
|
|
|
[ "services" "unclutter" "threshold" ])
|
|
|
|
];
|
|
|
|
|
2019-12-04 16:07:45 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ rnhmjoj ];
|
|
|
|
|
2015-03-09 03:04:33 +00:00
|
|
|
}
|