diff options
Diffstat (limited to 'modules/nixos/hardware')
| -rw-r--r-- | modules/nixos/hardware/rgb/default.nix | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/nixos/hardware/rgb/default.nix b/modules/nixos/hardware/rgb/default.nix new file mode 100644 index 0000000..81e633f --- /dev/null +++ b/modules/nixos/hardware/rgb/default.nix @@ -0,0 +1,32 @@ +{ options, config, lib, pkgs, namespace, ... }: + +with lib; with lib.${namespace}; let + cfg = config.${namespace}.hardware.rgb; +in { + options.${namespace}.hardware.rgb = with types; { + enable = mkEnableOption "rgb support"; + headphones = mkEnableOption "headphone support"; + }; + + config = mkIf cfg.enable { + # magic shit :3 + systemd.services."${namespace}.headphone-rgb-disable" = let + id = "046D:0B1F"; + magic = "11 ff 08 00 0e"; + command = "${pkgs.openrgb}/bin/openrgb -d 'G733 Gaming Headset' --mode off"; + script = pkgs.writeShellScript "headphone-rgb-disable" '' + ${command} + ${pkgs.gnugrep}/bin/grep --line-buffered -F '${magic}' /sys/kernel/debug/hid/*:${id}.*/events | while read; do ${command}; done + ''; + in { + enable = cfg.headphones; + wantedBy = [ "multi-user.target" ]; + serviceConfig.ExecStart = script; + }; + + services = { + hardware.openrgb.enable = true; + udev.enable = true; + }; + }; +} |