Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show current colors, effect, speed, and wave_dir in --list_devices #51

Closed
GM-Script-Writer-62850 opened this issue Jan 30, 2021 · 9 comments

Comments

@GM-Script-Writer-62850
Copy link

These features are in the daily build of openrazer
https://github.com/openrazer/openrazer/blob/master/pylib/openrazer/client/fx.py#L72-L109
While in the process of making this work i found something strange:
This causes a error, aside from using try do you know any other solution?

  • hasattr(device,'brightness')

So far this is what I have for output:

~/.local/bin/razer-cli -l
Found 1 Razer device(s)
Razer DeathAdder Elite:
   type: mouse
   DPI: (1100, 1100)
   max DPI: 16000
   polling rate: 500
   logo settings:
      brightness: 50.0
      colors: ['755D92', 'FF00FF', '0000FF']
      effect: breathSingle
      speed: 1
      wave_dir: 1
   scroll_wheel settings:
      brightness: 50.0
      colors: ['755D92', 'FF00FF', '0000FF']
      effect: breathSingle
      speed: 1
      wave_dir: 1
   serial: 321848H04401822
   firmware version: v1.6
   driver version: 2.9.0
   supported capabilities: name, type, firmware_version, serial, lighting, lighting_led_matrix, lighting_logo, lighting_logo_brightness, lighting_logo_spectrum, lighting_logo_static, lighting_logo_none, lighting_logo_reactive, lighting_logo_breath_single, lighting_logo_breath_dual, lighting_logo_breath_random, lighting_scroll, lighting_scroll_brightness, lighting_scroll_spectrum, lighting_scroll_static, lighting_scroll_none, lighting_scroll_reactive, lighting_scroll_breath_single, lighting_scroll_breath_dual, lighting_scroll_breath_random, poll_rate, dpi
   lighting zone generic supports: none, breath_single, breath_dual, breath_triple, breath_random, reactive, ripple, ripple_random, spectrum, starlight_single, starlight_dual, starlight_random, static, wave, multicolor
   lighting zone logo supports: none, brightness, breath_single, breath_dual, breath_random, blinking, reactive, pulsate, spectrum, static, wave
   lighting zone scroll_wheel supports: none, brightness, breath_single, breath_dual, breath_random, blinking, reactive, pulsate, spectrum, static, wave

Seems strange my mouse has 3 colors in memory and I can't use breath_triple

@LoLei
Copy link
Owner

LoLei commented Jan 31, 2021

You mean this error?

dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: getBrightness is not a valid method of interface razer.device.lighting.brightness

Seems like it only occurs when calling hasattr(device, 'brightness') on my mouse, with the keyboard it works. That also means it works within if device.has('brightness'), but not if that returns false. Which is weird indeed as those two methods should essentially have the same function.

@GM-Script-Writer-62850
Copy link
Author

GM-Script-Writer-62850 commented Jan 31, 2021

can you let me know what the output of for these is on your hardware?
aside from brightness, these are not in the stable branch of openrazer
device.brightness
** if you are on the stable and intend to upgrade to test this, please do a before and after upgrade

for i in ['brightness','colors', 'speed', 'wave_dir']:
   try:
      print(i,'has',device.has(i))
      print('   ',getattr(device,i))
   except:
      print(i,'has error\n')
   try:
      print(i,'hasattr',device.hasattr(i))
      print('   ',getattr(device,i))
   except:
      print(i,'hasattr error\n')
   try:
      print(i,'fx has',device.fx.has(i))
      print('   ',getattr(device.fx,i))
   except:
      print(i,'fx has error\n')
   try
      print(i,'fx hasattr',device.fx.hasattr(i))
      print('   ',getattr(device.fx,i))
   except:
      print(i,'fx hasattr error\n')
   try:
      print(i,'fx misc has',device.fx.misc.has(i))
      print('   ',getattr(device.fx.misc,i))
   except:
      print(i,'fx misc has error\n')
   try
      print(i,'fx misc hasattr',device.fx.misc.hasattr(i))
      print('   ',getattr(device.fx.misc,i))
   except:
      print(i,'fx misc hasattr error\n')
   print("\n\n")

@GM-Script-Writer-62850
Copy link
Author

Do you think this looks better with or without the commas?

$ ~/.local/bin/razer-cli -l
Found 1 Razer device(s)
Razer DeathAdder Elite:
   type: mouse
   DPI: (1100, 1100)
   max DPI: 16000
   polling rate: 1000
   generic zone:
      effects available: multicolor
   logo zone:
      brightness: 0.0
      colors: ['4BEA4A', 'F9992C', '0000FF']
      effect: none
      speed: 1
      wave_dir: 1
      effects available: none, brightness, breath_single, breath_dual, breath_random, reactive, spectrum, static
   scroll_wheel zone:
      brightness: 0.0
      colors: ['4BEA4A', 'F9992C', '0000FF']
      effect: static
      speed: 3
      wave_dir: 1
      effects available: none, brightness, breath_single, breath_dual, breath_random, reactive, spectrum, static
   serial: 321848H04401822
   firmware version: v1.6
   driver version: 2.9.0
   supported capabilities: name, type, firmware_version, serial, lighting, lighting_led_matrix, lighting_logo, lighting_logo_brightness, lighting_logo_spectrum, lighting_logo_static, lighting_logo_none, lighting_logo_reactive, lighting_logo_breath_single, lighting_logo_breath_dual, lighting_logo_breath_random, lighting_scroll, lighting_scroll_brightness, lighting_scroll_spectrum, lighting_scroll_static, lighting_scroll_none, lighting_scroll_reactive, lighting_scroll_breath_single, lighting_scroll_breath_dual, lighting_scroll_breath_random, poll_rate, dpi

@LoLei
Copy link
Owner

LoLei commented Feb 1, 2021

I'd leave the commas.

@LoLei
Copy link
Owner

LoLei commented Feb 1, 2021

The output of this is

device.name='Razer Lancehead Tournament Edition'
brightness has False
brightness has error

brightness hasattr error

brightness fx has False
brightness fx has error

brightness fx hasattr error

brightness fx misc has False
brightness fx misc has error

brightness fx misc hasattr error




colors has False
colors has error

colors hasattr error

colors fx has False
colors fx has error

colors fx hasattr error

colors fx misc has False
colors fx misc has error

colors fx misc hasattr error




speed has False
speed has error

speed hasattr error

speed fx has False
speed fx has error

speed fx hasattr error

speed fx misc has False
speed fx misc has error

speed fx misc hasattr error




wave_dir has False
wave_dir has error

wave_dir hasattr error

wave_dir fx has False
wave_dir fx has error

wave_dir fx hasattr error

wave_dir fx misc has False
wave_dir fx misc has error

wave_dir fx misc hasattr error




device.name='Razer BlackWidow X Chroma Tournament Edition'
brightness has True
    100.0
brightness hasattr error

brightness fx has False
brightness fx has error

brightness fx hasattr error

brightness fx misc has False
brightness fx misc has error

brightness fx misc hasattr error




colors has False
colors has error

colors hasattr error

colors fx has False
    b'HKT\x00\xff\x00\x00\x00\xff'
colors fx hasattr error

colors fx misc has False
colors fx misc has error

colors fx misc hasattr error




speed has False
speed has error

speed hasattr error

speed fx has False
    2
speed fx hasattr error

speed fx misc has False
speed fx misc has error

speed fx misc hasattr error




wave_dir has False
wave_dir has error

wave_dir hasattr error

wave_dir fx has False
    1
wave_dir fx hasattr error

wave_dir fx misc has False
wave_dir fx misc has error

wave_dir fx misc hasattr error

I am on the following versions:

aur/python-openrazer-git 2.6.0.r6.g2433ae8-1 [+7 ~0.00] [Installed: 2.9.0.r19.g9ea49c8d-1]
    Python library for accessing the Razer daemon from Python.
aur/openrazer-daemon-git 2.6.0.r6.g2433ae8-1 [+7 ~0.00] [Installed: 2.9.0.r19.g9ea49c8d-1]
    Userspace daemon that abstracts access to the kernel driver. Provides a
    DBus service for applications to use.
aur/openrazer-driver-dkms-git 2.6.0.r6.g2433ae8-1 [+7 ~0.00] [Installed: 2.9.0.r19.g9ea49c8d-1]
    Kernel driver for Razer devices (DKMS-variant)
aur/openrazer-meta-git 2.6.0.r6.g2433ae8-1 [+7 ~0.00] [Installed: 2.9.0.r19.g9ea49c8d-1]
    Meta package for installing all required openrazer packages.

@GM-Script-Writer-62850
Copy link
Author

razer-cli.zip
Here is a dev version based on https://github.com/LoLei/razer-cli/tree/feature/effect-rewrite

Sorry the patch file has a size of 60959 (60K)

  • Add --battery support
  • support -dfor -l
  • add --version
  • add -ls/--list_devices_short
  • remove -lh
    • you can use -l, -ll, and -ls these can be combined with -v for even more info
  • add support for active property/effect
  • add support for reading existing device colors
  • use current device colors if none is given, see -man color
  • move manual pages to files
  • use hasattr less in favor of device.capabilities
  • allow use of serial number for -d
  • sweeping changes to -l
  • moved some code around trying to organize it

@GM-Script-Writer-62850
Copy link
Author

With your 'Razer BlackWidow X Chroma Tournament Edition' it is interesting that hasattr fails even though the property exist and has valid data looks like you use green and blue colors on it
how does getattr(device.fx,'colors') not error and at the same time hasattr(device.fx,'colors') fail

@GM-Script-Writer-62850
Copy link
Author

Managed to reduce some redundant code and fixed a oversight that could produce a bug if a device actually supported such a thing (multicolor only worked in the generic zone)
razer-cli-dev.zip
the patch file is larger, but the razer_cli.py file should be smaller than in the above attachment (i hope)
also you can now set the refresh rate for ripple & ripple_random (in theory)

@LoLei
Copy link
Owner

LoLei commented Feb 2, 2021

I've added everything to #52.

Since you added so much help text, we might as well just ship "real" man pages as well. Those are written in groff, and can apparently be bundled with a Python package.

pypa/packaging-problems#72
https://stackoverflow.com/a/48381612/4644044

Not a must-have, but a suggestion if you wanna try that out.

@LoLei LoLei closed this as completed Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants