From b236a7817a95b42a4392327ee77f3262755e11e1 Mon Sep 17 00:00:00 2001 From: Ivor Wanders Date: Sun, 26 Nov 2023 15:44:14 -0500 Subject: [PATCH] Write iptsd configuration file. --- microsoft/surface/common/ipts/default.nix | 27 +++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/microsoft/surface/common/ipts/default.nix b/microsoft/surface/common/ipts/default.nix index 4d19aa0..ea13c9f 100644 --- a/microsoft/surface/common/ipts/default.nix +++ b/microsoft/surface/common/ipts/default.nix @@ -1,18 +1,39 @@ { config, lib, pkgs, ... }: let - inherit (lib) mkDefault mkEnableOption mkIf mkMerge; + inherit (lib) mkDefault mkEnableOption mkIf mkMerge mkOption types; cfg = config.microsoft-surface.ipts; -in { + iptsConfFile = pkgs.writeTextFile { + name = "iptsd.conf"; + text = lib.generators.toINI { } cfg.config; + }; + +in +{ options.microsoft-surface.ipts = { enable = mkEnableOption "Enable IPTSd for Microsoft Surface"; + + config = mkOption { + type = types.attrs; + default = { }; + description = '' + Values to wrote to iptsd.conf, first key is section, second key is property. + See the example config; https://github.com/linux-surface/iptsd/blob/v1.4.0/etc/iptsd.conf + ''; + example = '' + DFT = { + ButtonMinMag = 1000; + }; + ''; + }; }; config = mkMerge [ { microsoft-surface.ipts.enable = mkDefault false; + } (mkIf cfg.enable { @@ -22,6 +43,8 @@ in { script = "iptsd $(iptsd-find-hidraw)"; wantedBy = [ "multi-user.target" ]; }; + + environment.etc."iptsd/iptsd.conf".source = "${iptsConfFile}"; }) ]; }