yep, more dotfiles
1{ config
2, lib
3, pkgs
4, ...
5}:
6
7let
8 cfg = config.services.logiops;
9
10 libconfig-format = pkgs.formats.libconfig { };
11 rendered-config = libconfig-format.generate "logid.cfg" cfg.settings;
12in
13{
14 options.services.logiops = with lib; {
15 enable = mkEnableOption (mdDoc "Logiops HID++ configuration");
16
17 package = mkPackageOption pkgs "logiops" { };
18
19 settings = mkOption {
20 type = libconfig-format.type;
21 default = { };
22 example = {
23 devices = [{
24 name = "Wireless Mouse MX Master 3";
25
26 smartshift = {
27 on = true;
28 threshold = 20;
29 };
30
31 hiresscroll = {
32 hires = true;
33 invert = false;
34 target = false;
35 };
36
37 dpi = 1500;
38
39 buttons = [
40 {
41 cid = "0x53";
42 action = {
43 type = "Keypress";
44 keys = [ "KEY_FORWARD" ];
45 };
46 }
47 {
48 cid = "0x56";
49 action = {
50 type = "Keypress";
51 keys = [ "KEY_BACK" ];
52 };
53 }
54 ];
55 }];
56 };
57 description = mdDoc ''
58 Logid configuration. Refer to
59 [the `logiops` wiki](https://github.com/PixlOne/logiops/wiki/Configuration)
60 for details on supported values.
61 '';
62 };
63 };
64
65 config = lib.mkIf cfg.enable {
66 services.udev.packages = [ pkgs.logitech-udev-rules ];
67 environment.etc."logid.cfg".source = rendered-config;
68
69 systemd.packages = [ cfg.package ];
70 systemd.services.logid = {
71 wantedBy = [ "multi-user.target" ];
72 restartTriggers = [ rendered-config ];
73 };
74 };
75
76 meta.maintainers = with lib.maintainers; [ ckie ];
77}