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