skraus-dev / cherryrgb-rs

Cherry RGB Keyboard - Multi platform tool to set RGB LEDs for Cherry keyboards
MIT License
41 stars 3 forks source link

software needs sudo to detect keyboard #4

Closed starsforeveryone closed 1 year ago

starsforeveryone commented 2 years ago

Hey dear developers!

I've tested your software on the lastest Fedora 37 with my MX 10.0N RGB and it's working perfectly so far with root access / sudo.

Since this is a bit overkill for a keyboard illumination software, I tried to grant it access to the keyboard via udev (as described in the Arch wiki under section 4.2) by creating /etc/udev/rules.d/cherry-keyboard with following contents: SUBSYSTEMS=="usb", ATTRS{idVendor}=="046a", ATTRS{idProduct}=="00df", MODE="0660", TAG+="uaccess"

Even after a reboot, the device detection fails:

cherryrgb_cli -b full animation static fast ffffff
Error: Failed to create keyboard

Caused by:
    Keyboard not found

Using sudo, everything works. Maybe you could modify your software to work with udev or give me a hint on how to do it the right way?

eflukx commented 2 years ago

I think this tool/library tries to access PID/idProduct 0x00dd (not 0x00df). see: https://github.com/skraus-dev/cherryrgb-rs/blob/master/cherryrgb/src/lib.rs#L75

felfert commented 1 year ago

@starsforeveryone

described in the Arch wiki under section 4.2) by creating /etc/udev/rules.d/cherry-keyboard with following contents:

I don't use arch, but on pretty much any other Linux distro, the rules files MUST have the extension .rules in order to be properly recognized. You can test an udev rule by running udevadm monitor and then plugging-in your device. Obviously, you need TWO keyboards temporarily for doing that in this case.

Also: Your udev entry grants group access, so your invoking user must be in the proper group so maybe mode 0660 is not enough.

If you don't want to mess with udev, you always can make the binary setuid-root instead. E.g.:

sudo chown root.root /path/to/your/cherryrgb_cli
sudo chmod u+s /path/to/your/cherryrgb_cli

@eflukx

I think this tool/library tries to access PID/idProduct 0x00dd (not 0x00df).

No, it doesn't. That declaration you linked is referenced nowhere else in the code.

skraus-dev commented 1 year ago

The instructions and a sample udev rules file is now incorporated into the repository, README and release archives for linux builds.