flozz / rivalcfg

CLI tool and Python library to configure SteelSeries gaming mice
https://flozz.github.io/rivalcfg/
Do What The F*ck You Want To Public License
792 stars 65 forks source link

Dumps trace w/ mouse plugged in #170

Closed ggl closed 2 years ago

ggl commented 2 years ago

Rivalcfg dumps trace with mouse plugged in and udev rules not installed. As a consequence --print-udev, --help and the other help switches cannot be displayed. I installed it into my home directory, so sudo rivalcfg --update-udev does not work since root env doesn't know about the local python lib path.

rivalcfg --help
W: udev rules are not installed. You may not be able to open the device using a regular user.
   Run 'rivalcfg --update-udev' as root to fix.

Traceback (most recent call last):
  File "/home/gelu/.local/bin/rivalcfg", line 8, in <module>
    sys.exit(main())
  File "/home/gelu/.local/lib/python3.6/site-packages/rivalcfg/__main__.py", line 52, in main
    mouse = get_first_mouse()
  File "/home/gelu/.local/lib/python3.6/site-packages/rivalcfg/__init__.py", line 29, in get_first_mouse
    product_id=plugged_devices[0]["product_id"])
  File "/home/gelu/.local/lib/python3.6/site-packages/rivalcfg/mouse.py", line 30, in get_mouse
    hid_device = usbhid.open_device(vendor_id, product_id, profile["endpoint"])
  File "/home/gelu/.local/lib/python3.6/site-packages/rivalcfg/usbhid.py", line 93, in open_device
    device.open_path(path)
  File "hid.pyx", line 125, in hid.device.open_path
flozz commented 2 years ago

That's strange, --print-udev should not even try to open the device :/

Does the following command work?

rivalcfg --print-debug

Can you also try?

RIVALCFG_DRY=1 rivalcfg --help
RIVALCFG_DRY=1 rivalcfg --print-udev
ggl commented 2 years ago

It only tries to open the device when you have a compatible mouse plugged in and no udev rules installed.

With --print-debug and any other command including --help it still tries to open the device. The trace message is the same every time.

RIVALCFG_DRY=1 rivalcfg --help
RIVALCFG_DRY=1 rivalcfg --print-udev

The above work fine and print everything as intended.

flozz commented 2 years ago

Ok, I will look at that...

To solve your issue:

:)

ggl commented 2 years ago

Thank you. I managed to fix it before reporting the bug but it took a while until I found the RIVALCFG_DRY=1 environment variable.

flozz commented 2 years ago

Ok, thank you again for your repport.

I will try to fix permission issues when Rivalcfg is used with debug / help / version options :)

flozz commented 2 years ago

I made a fix on master. Now rivalcfg should not try to open devices when not needed, and the error is catched with -h and --help :)