User:Mvasi90/Disable SteelSeries RGB lights

From ArchWiki

Wikipedia:SteelSeries is a manufacturer of gaming peripherals and accessories. Most of them have built-in RGB lights, which are sometimes impossible to deactivate without proprietary software (which only works on Windows).

Sometimes users who choose a certain laptop taking into account its hardware have no choice but to accept RGB lights, even if they are not gamers or don't like RGB lights.

This article describes how to safely and easily disable RGB lights directly from the Linux kernel, without using third-party software.

If instead you want to keep RGB lights active and manipulate their behavior, you can install the openrgbAUR tool.

Warning: Tools like openrgbAUR have been created using reverse engineering and can damage your hardware.

From https://gitlab.com/CalcProgrammer1/OpenRGB#warning:

There have been two instances of hardware damage in OpenRGB's development and we've taken precautions to prevent it from happening again.
It is possible to change the color using HID interface, which using python and doesn't require a daemon.

Another drawback of this type of software is that it usually starts with the system and sometimes it is even necessary to keep the daemon running.

Continue reading if you want to disable RGB lights, like Mystic light bar, without installing third-party software.

Hardware identification

First you have to familiarize yourself with the hardware you own. RGB SteelSeries usually use USB connection and appear as Human Interface Device Wikipedia:HID.

For this example the laptop MSI Raider GE77 HX is used. We know that there is two RGB devices connected to the laptop: One is the RGB keyboard and the other is the Mystic RGB light bar.

The keyboard RGB light can be turned off by doing a key combination, but the Mystic bar light can't.

Use the following command to see the list of USB devices:

$ lsusb -tvv

You will see a list of devices, among which is SteelSeries:

...
  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub
    /sys/bus/usb/devices/usb1  /dev/bus/usb/001/001
    |__ Port 8: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        ID 1038:113a SteelSeries ApS 
        /sys/bus/usb/devices/1-8  /dev/bus/usb/001/002
    |__ Port 8: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        ID 1038:113a SteelSeries ApS 
        /sys/bus/usb/devices/1-8  /dev/bus/usb/001/002
    |__ Port 9: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        ID 1038:113e SteelSeries ApS 
        /sys/bus/usb/devices/1-9  /dev/bus/usb/001/003
    |__ Port 9: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        ID 1038:113e SteelSeries ApS 
        /sys/bus/usb/devices/1-9  /dev/bus/usb/001/003
 ...

Alternatively you can use the following command to get the same result:

$ grep -i "steelseries" /sys/bus/usb/devices/*/manufacturer

In this case, the output should be something like this:

/sys/bus/usb/devices/1-8/manufacturer:SteelSeries
/sys/bus/usb/devices/1-9/manufacturer:SteelSeries

In both cases the result is the same, except that the first one is more detailed.

There are two HID devices. The first one is connected on the Bus 1 and the Port 8 (1-8), and the second one is connected on the Bus 1 and the Port 9 (1-9).

Trying to suspend it and unbind the driver manually

After locating the devices, you need to identify them.

Note: Make sure you have your RGB keyboard backlight turned on so you can identify the device to be turned off.

The manual procedure performed in this section is temporary. That means that when you restart the laptop, everything will be back to the way it was before.

Enable autosuspend

When enabling suspend nothing happens because the driver is still bound. But this step is necessary.

First device (1-8)

$ echo "auto" | sudo tee /sys/bus/usb/devices/1-8/power/control

Second device (1-9)

$ echo "auto" | sudo tee /sys/bus/usb/devices/1-9/power/control

Unbind the driver

Then unbind the USB driver for the first device to see which one turns off: the keyboard light or the mystic light.

Note: The keyboard itself will not be affected. It will continue to work. Only the backlight is switched off.

First device (1-8)

$ echo "1-8" | sudo tee /sys/bus/usb/drivers/usb/unbind

The keyboard RGB light is turned off. Great. Now we can turn it back on:

$ echo "1-8" | sudo tee /sys/bus/usb/drivers/usb/bind

Second device (1-9)

$ echo "1-9" | sudo tee /sys/bus/usb/drivers/usb/unbind

Eureka! The mystic light is turned off. The second device (1-9) is the mystic bar.

Create udev rules to keep the mystic light turned off

If you have used the lsusb -tvv command, you already know the vendor's ID (1038) and the device's ID (113e) of the second device 1-9.

On the other hand, if you have used the cat command, you already have the device path, and you can use the next command to get the idVendor and idProduct.

udevadm info --attribute-walk /sys/bus/usb/devices/1-9 

Create the next udev rules in /etc/udev/rules.d/80-no-mystic-light.rules

ACTION=="bind",SUBSYSTEM=="usb",ATTR{idVendor}=="1038",ATTR{idProduct}=="113e",TEST=="power/control",ATTR{power/control}="auto"
ACTION=="bind",SUBSYSTEM=="usb",ATTR{idVendor}=="1038",ATTR{idProduct}=="113e",TEST=="power/autosuspend_delay_ms",ATTR{power/autosuspend_delay_ms}="0"
ACTION=="bind",SUBSYSTEM=="usb",ATTR{idVendor}=="1038",ATTR{idProduct}=="113e",RUN+="/bin/sh -c 'echo $kernel > /sys/bus/usb/drivers/usb/unbind'"
Warning: Don't forget to replace the idVendor and idProduct with those of your device.
Tip: If your device is an external (Plug and Play) device, and you want to test it without reboot, you can reload the udev:
udevadm control --reload

udev rules in initramfs

As this is a HID device, it is loaded by the kernel early, before the root partition is mounted (or decrypted), and your rules never will be triggered.

To solve this, you should add the file /etc/udev/rules.d/80-no-mystic-light.rules to the initramfs. Edit the file /etc/mkinitcpio.conf and add it to the FILES array:

FILES=(... '/etc/udev/rules.d/80-mystic-light.rules' ...)

Regenerate the initramfs, but rememeber to mount the boot partition before:

mkinitcpio -P

Now you can restart the computer to test it. The Mystic light will be turned off early, when the initramfs is loaded.