From 2ce64b8273bf239c2c6c3a65e3372c4344933ee5 Mon Sep 17 00:00:00 2001 From: Caroline Larimore Date: Sat, 3 May 2025 13:29:29 -0700 Subject: c-pc: magic headphone rbg script --- modules/nixos/hardware/rgb/default.nix | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 modules/nixos/hardware/rgb/default.nix (limited to 'modules/nixos/hardware/rgb/default.nix') 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; + }; + }; +} -- cgit v1.2.3