about summary refs log tree commit diff
path: root/nixos/modules/services/hardware/iptsd.nix
blob: bfd4b35227923deefda4803ba88e7c7279664336 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ config, lib, pkgs, ... }:

let
  cfg = config.services.iptsd;
  format = pkgs.formats.ini { };
  configFile = format.generate "iptsd.conf" cfg.config;
in {
  options.services.iptsd = {
    enable = lib.mkEnableOption "the userspace daemon for Intel Precise Touch & Stylus";

    config = lib.mkOption {
      default = { };
      description = ''
        Configuration for IPTSD. See the
        [reference configuration](https://github.com/linux-surface/iptsd/blob/master/etc/iptsd.conf)
        for available options and defaults.
      '';
      type = lib.types.submodule {
        freeformType = format.type;
        options = {
          Touchscreen = {
            DisableOnPalm = lib.mkOption {
              default = false;
              description = "Ignore all touchscreen inputs if a palm was registered on the display.";
              type = lib.types.bool;
            };
            DisableOnStylus = lib.mkOption {
              default = false;
              description = "Ignore all touchscreen inputs if a stylus is in proximity.";
              type = lib.types.bool;
            };
          };
          Stylus = {
            Disable = lib.mkOption {
              default = false;
              description = "Disables the stylus. No stylus data will be processed.";
              type = lib.types.bool;
            };
          };
        };
      };
    };
  };

  config = lib.mkIf cfg.enable {
    warnings = lib.optional (lib.hasAttr "Touch" cfg.config) ''
      The option `services.iptsd.config.Touch` has been renamed to `services.iptsd.config.Touchscreen`.
    '';

    systemd.packages = [ pkgs.iptsd ];
    environment.etc."iptsd.conf".source = configFile;
    systemd.services."iptsd@".restartTriggers = [ configFile ];
    services.udev.packages = [ pkgs.iptsd ];
  };

  meta.maintainers = with lib.maintainers; [ dotlambda ];
}