From d08a7b8c2d9017927824bd470ac11eb0bb4d514b Mon Sep 17 00:00:00 2001 From: William Hsieh Date: Wed, 5 Jun 2024 20:14:08 +0800 Subject: [PATCH] refactor(nix): extract logiops module --- system/default.nix | 82 +++------------------------------------------- system/logiops.nix | 75 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 78 deletions(-) create mode 100644 system/logiops.nix diff --git a/system/default.nix b/system/default.nix index 09113e09..ce7697a0 100644 --- a/system/default.nix +++ b/system/default.nix @@ -5,11 +5,10 @@ { config, pkgs, ... }: { - imports = - [ - # Include the results of the hardware scan. - ./hardware.nix - ]; + imports = [ + ./hardware.nix + ./logiops.nix + ]; boot = { kernelPackages = pkgs.linuxPackages_zen; @@ -20,7 +19,6 @@ }; }; - networking.hostName = (import ./config.nix).host; # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. @@ -165,76 +163,4 @@ # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "24.05"; # Did you read the comment? - - systemd.services.logiops = { - description = "An unofficial userspace driver for HID++ Logitech devices"; - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.logiops}/bin/logid"; - }; - }; - - # NOTE: https://github.com/PixlOne/logiops/blob/main/logid.example.cfg - environment.etc."logid.cfg".text = '' - devices: ({ - name: "Wireless Mouse MX Master 3"; - smartshift: { - on: true; - threshold: 12; - }; - hiresscroll: { - hires: true; - target: false; - }; - dpi: 1200; - buttons: ({ - cid: 0xc3; - action = { - type: "Gestures"; - gestures: ({ - direction: "Left"; - mode: "OnRelease"; - action = { - type = "Keypress"; - keys: ["KEY_F15"]; - }; - }, { - direction: "Right"; - mode: "OnRelease"; - action = { - type = "Keypress"; - keys: ["KEY_F16"]; - }; - }, { - direction: "Down"; - mode: "OnRelease"; - action = { - type: "Keypress"; - keys: ["KEY_F17"]; - }; - }, { - direction: "Up"; - mode: "OnRelease"; - action = { - type: "Keypress"; - keys: ["KEY_F18"]; - }; - }, { - direction: "None"; - mode: "OnRelease"; - action = { - type = "Keypress"; - keys: ["KEY_PLAYPAUSE"]; - }; - }); - }; - }, { - cid: 0xc4; - action = { - type: "Keypress"; - keys: ["KEY_F19"]; - }; - }); - }); - ''; } diff --git a/system/logiops.nix b/system/logiops.nix new file mode 100644 index 00000000..66445ac7 --- /dev/null +++ b/system/logiops.nix @@ -0,0 +1,75 @@ +{ pkgs, ... }: + +{ + systemd.services.logiops = { + description = "An unofficial userspace driver for HID++ Logitech devices"; + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.logiops}/bin/logid"; + }; + }; + + # NOTE: https://github.com/PixlOne/logiops/blob/main/logid.example.cfg + environment.etc."logid.cfg".text = '' + devices: ({ + name: "Wireless Mouse MX Master 3"; + smartshift: { + on: true; + threshold: 12; + }; + hiresscroll: { + hires: true; + target: false; + }; + dpi: 1200; + buttons: ({ + cid: 0xc3; + action = { + type: "Gestures"; + gestures: ({ + direction: "Left"; + mode: "OnRelease"; + action = { + type = "Keypress"; + keys: ["KEY_F15"]; + }; + }, { + direction: "Right"; + mode: "OnRelease"; + action = { + type = "Keypress"; + keys: ["KEY_F16"]; + }; + }, { + direction: "Down"; + mode: "OnRelease"; + action = { + type: "Keypress"; + keys: ["KEY_F17"]; + }; + }, { + direction: "Up"; + mode: "OnRelease"; + action = { + type: "Keypress"; + keys: ["KEY_F18"]; + }; + }, { + direction: "None"; + mode: "OnRelease"; + action = { + type = "Keypress"; + keys: ["KEY_PLAYPAUSE"]; + }; + }); + }; + }, { + cid: 0xc4; + action = { + type: "Keypress"; + keys: ["KEY_F19"]; + }; + }); + }); + ''; +}