{ lib, pkgs, config, ... }: let cfg = config.ptw.services.logiops; in { options.ptw.services.logiops = { enable = lib.mkEnableOption "Enable logiops"; renice = lib.mkOption { description = "Set the nice value of the process"; default = true; }; reniceValue = lib.mkOption { description = "Set the nice value of the process"; default = -19; }; }; config = lib.mkIf true { systemd.services.logiops = { description = "An unofficial userspace driver for HID++ Logitech devices"; wantedBy = [ "default.target" ]; serviceConfig = let logiopsConfig = pkgs.writeText "logiops.cfg" '' devices: ( { name: "Wireless Mouse MX Master 3"; hiresscroll: { hires: true; target: false; }; smartshift: { on: true; threshold: 30; default_threshold: 30; }; dpi: 800; } ); ''; in { Type = "simple"; ExecStart = let renice = lib.optionalString cfg.renice "${pkgs.coreutils-full}/bin/nice -n ${builtins.toString cfg.reniceValue}"; in "${renice} ${pkgs.logiops}/bin/logid -c ${logiopsConfig}"; }; }; }; }