home-manager/modules/services/unclutter.nix

70 lines
1.7 KiB
Nix
Raw Normal View History

2018-03-04 07:53:10 +01:00
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.unclutter;
in {
options.services.unclutter = {
enable = mkEnableOption (lib.mdDoc "unclutter");
2018-03-04 07:53:10 +01:00
package = mkOption {
description = lib.mdDoc "unclutter derivation to use.";
2018-03-04 07:53:10 +01:00
type = types.package;
default = pkgs.unclutter-xfixes;
defaultText = literalExpression "pkgs.unclutter-xfixes";
2018-03-04 07:53:10 +01:00
};
timeout = mkOption {
description =
lib.mdDoc "Number of seconds before the cursor is marked inactive.";
2018-03-04 07:53:10 +01:00
type = types.int;
default = 1;
};
threshold = mkOption {
description =
lib.mdDoc "Minimum number of pixels considered cursor movement.";
2018-03-04 07:53:10 +01:00
type = types.int;
default = 1;
};
extraOptions = mkOption {
description =
lib.mdDoc "More arguments to pass to the unclutter command.";
2018-03-04 07:53:10 +01:00
type = types.listOf types.str;
default = [ ];
example = [ "exclude-root" "ignore-scrolling" ];
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.unclutter" pkgs
lib.platforms.linux)
];
2018-03-04 07:53:10 +01:00
systemd.user.services.unclutter = {
Unit = {
Description = "unclutter";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart = ''
${cfg.package}/bin/unclutter \
--timeout ${toString cfg.timeout} \
--jitter ${toString (cfg.threshold - 1)} \
${concatMapStrings (x: " --${x}") cfg.extraOptions}
'';
RestartSec = 3;
Restart = "always";
};
2020-02-02 00:39:17 +01:00
Install = { WantedBy = [ "graphical-session.target" ]; };
2018-03-04 07:53:10 +01:00
};
};
}