1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let cfg = config.services.tp-auto-kbbl;
6
7in {
8 meta.maintainers = with maintainers; [ sebtm ];
9
10 options = {
11 services.tp-auto-kbbl = {
12 enable = mkEnableOption "auto toggle keyboard back-lighting on Thinkpads (and maybe other laptops) for Linux";
13
14 package = mkPackageOption pkgs "tp-auto-kbbl" { };
15
16 arguments = mkOption {
17 type = types.listOf types.str;
18 default = [ ];
19 description = ''
20 List of arguments appended to `./tp-auto-kbbl --device [device] [arguments]`
21 '';
22 };
23
24 device = mkOption {
25 type = types.str;
26 default = "/dev/input/event0";
27 description = "Device watched for activities.";
28 };
29
30 };
31 };
32
33 config = mkIf cfg.enable {
34 environment.systemPackages = [ cfg.package ];
35
36 systemd.services.tp-auto-kbbl = {
37 serviceConfig = {
38 ExecStart = concatStringsSep " "
39 ([ "${cfg.package}/bin/tp-auto-kbbl" "--device ${cfg.device}" ] ++ cfg.arguments);
40 Restart = "always";
41 Type = "simple";
42 };
43
44 unitConfig = {
45 Description = "Auto toggle keyboard backlight";
46 Documentation = "https://github.com/saibotd/tp-auto-kbbl";
47 After = [ "dbus.service" ];
48 };
49
50 wantedBy = [ "multi-user.target" ];
51 };
52 };
53}