Coder Social home page Coder Social logo

razer-cli's Introduction

razer-cli

All Contributors

Command line interface for controlling Razer devices on Linux

About

With this command line interface you can configure your Razer peripherals, such as keyboard and mouse, set their colors and effects, etc.

The most simple use case (for which this tool was originally developed) is to use it in symbiosis with pywal. Then this tool will set your Razer colors to Pywal's colors. See below for more information.

Installation

pip install razer-cli

OR

git clone https://github.com/LoLei/razer-cli.git
cd razer-cli
sudo python setup.py install

OR

git clone https://github.com/LoLei/razer-cli.git
cd razer-cli
pip install . --user

Usage

$ razer-cli -h
usage: razer-cli [-h] [-man [MANUAL ...]] [-v] [-d DEVICE [DEVICE ...]]
                 [-a] [-e EFFECT [EFFECT ...]] [-c COLOR [COLOR ...]]
                 [-z ZONES [ZONES ...]] [-b BRIGHTNESS [BRIGHTNESS ...]]
                 [--dpi DPI] [--poll POLL]
                 [--battery BATTERY [BATTERY ...]] [-l] [-ll] [-ls]
                 [--sync] [--restore] [--version]

optional arguments:
  -h, --help            show this help message and exit
  -man [MANUAL ...], --manual [MANUAL ...]
                        Print help details for given feature(s)
  -v, --verbose         increase output verbosity
  -d DEVICE [DEVICE ...], --device DEVICE [DEVICE ...]
                        only affect these devices, same name as output of
                        -l
  -a, --automatic       try to find colors and set them to all devices
                        without user arguments, uses X or pywal colors
  -e EFFECT [EFFECT ...], --effect EFFECT [EFFECT ...]
                        set effect
  -c COLOR [COLOR ...], --color COLOR [COLOR ...]
                        choose color (default: X color1), use one argument
                        for hex, or three for base10 rgb
  -z ZONES [ZONES ...], --zone ZONES [ZONES ...]
                        choose zone for color(s)
  -b BRIGHTNESS [BRIGHTNESS ...], --brightness BRIGHTNESS [BRIGHTNESS ...]
                        set brightness of device
  --dpi DPI             set DPI of device (use print as a value to show
                        it)
  --poll POLL           set polling rate of device (use print as a value
                        to show it)
  --battery BATTERY [BATTERY ...]
                        set low threshold and/or idle delay (use print as
                        a value to show it)
  -l, --list_devices    list available devices, settings, and their
                        supported capabilities/effects
  -ll, --list_devices_long
                        list available devices settings, and list their
                        supported capabilities/effects
  -ls, --list_devices_short
                        list available devices and their settings
  --sync                sync lighting effects to all supported Razer
                        products
  --restore             Load last used settings
  --version             Print version number

This might be out of date, just run it with -h yourself to see the newest options.

Example usage with Pywal

To get your mouse and keyboard to use Pywal's colors, simply start razer-cli with the -a flag, after having executed wal: razer-cli -a
Example in action here.

Another option is to use razer-cli -e multicolor,xpalette, which not only uses a single color from pywal, but uses the entire 16 color palette.

Other examples

$ razer-cli -e ripple -c ff0000
$ razer-cli -e static -c ffffff

You can also leave out the color or the effect:
$ razer-cli -e breath_single
$ razer-cli -c 55ff99

Currently this will imply the -a flag being used for the missing setting. I plan on also having the option to reuse the current color/effect, if the argument is missing, in the future.

Effects

Effects are listed in razer_cli/settings.py. The effects that are supported per device can be listed with razer-cli -l[l]. Some of the built-in effects or not implemented yet. If such an effect is chosen, a notice will be logged. There are also custom effects that do not exist normally, such as multicolor, which is described in the same file.

Here's a showcase of that effect:

Other symbiosis tools

Dependencies

  • openrazer
    • ⚠️ Do not install openrazer from pip, which is something else.
    • Instead install it from one of the various package managers of your distribution.
  • xrdb
    • Also available on most distros.

Disclaimer

Not all devices have been tested, but basic effects should work everywhere. Some guesswork is being done as to what capabilities are supported on specific devices. If you need more advanced configuration, consider using the GUIs Polychromatic, RazerGenie or RazerCommander which have specific implementations for most devices.

Feel free to open feature request issues or PRs.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Ansis
Ansis

💻
Kainoa Kanter
Kainoa Kanter

🤔
IFo Hancroft
IFo Hancroft

🐛 📓 📖
GM-Script-Writer-62850
GM-Script-Writer-62850

💻
Stephen Thomas-Dorin
Stephen Thomas-Dorin

💻
Romain Richard
Romain Richard

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

razer-cli's People

Contributors

allcontributors[bot] avatar ansis100 avatar ifohancroft avatar lolei avatar romainrichard avatar sk8ersteve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

razer-cli's Issues

[Patch] Make use of settings file and update color input to support many colors at once

settings+color_patch.zip
Looked like the settings file was a feature made for future use, i made a --restore option that will spit out commands to apply what is found in the file, also added new features to the settings file, also made the --color option allow multi color input

~/.local/bin/razer-cli --restore
Feature incomplete, here are the command(s) to restore the settings:
    razer-cli -d 'Razer DeathAdder Elite' -c 0 0 0 17 17 17 255 255 255 --dpi 1100 --poll 1000 -e static -b logo 0 scroll 0 generic 0 left 0 right 0

at present only the 1st color is used for anything, but it gives you the framework to get fancy with color input, not sure if there is a limit to how many colors you can input, maybe you will hit a max arguments count or something

No module named 'openrazer.client'

When running from pip package:

Traceback (most recent call last):
  File "/home/reese/.local/bin/razercli", line 5, in <module>
    from razercli.razercli import main
  File "/home/reese/.local/lib/python3.8/site-packages/razercli/razercli.py", line 12, in <module>
    from openrazer.client import DeviceManager
ModuleNotFoundError: No module named 'openrazer.client'

When running from latest source:

Traceback (most recent call last):
  File "razer_cli/razer_cli.py", line 12, in <module>
    from openrazer.client import DeviceManager
ModuleNotFoundError: No module named 'openrazer.client'

Note: I had to manually install openrazer because it threw No module named 'openrazer' before.

Python version: 3.8.2
pip version: 20.0.2

Multiple colors

Idea: add multiple colors in the cli, and spread them across keyboard rows/columns

[Request w/ Patch] Support for different X/Y DPI

Proposed change to this part of the script:
https://github.com/LoLei/razer-cli/blob/master/razer_cli/razer_cli.py#L140-L142

                # Actually set DPI
                args.dpi = args.dpi.split(',')
                if len(args.dpi) == 1:
                    args.dpi.append(int(args.dpi[0]))
                device.dpi = (int(args.dpi[0]), int(args.dpi[1]))

Example usage:

  • .local/bin/razer-cli -d "Razer DeathAdder Elite" --dpi 1200
  • .local/bin/razer-cli -d "Razer DeathAdder Elite" --dpi 1200,1000

It is a niche feature, but adding support is easy so why not?

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

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

[Patch] Flag for: device_manager.sync_effects = True/False

razer_cli.zip

Saw this:

    # Disable daemon effect syncing.
    # Without this, the daemon will try to set the lighting effect to every
    # device.
    # TODO: Could be enabled as flag
    device_manager.sync_effects = False

So here is your flag, not sure if it needed anything else to be useful, but if you just needed a flag here it is

Can't Autostart --restore on startup

My System specs:

Slackware 15.0
Openbox 3.6.1
openrazer 3.5.1

I'm trying to add razer-cli --restore to work at system startup, without having to always type it out when I log into X.

I've tried creating a .desktop file and then running it from the /.config/autostart start path;

[Desktop Entry]
Version=1.0
Name=razer-cli
Exec=razer-cli --restore
Icon=openrazer-chroma
Terminal=false
Type=Application
Categories=Utility;
StartupNotify=false

I've added the command two ways in my .xinitrc;

exec razer-cli --restore
exec /usr/bin/razer-cli --restore

I've also tried adding the cmd from the Openbox autostart.sh two ways at /.config/openbox/;

razer-cli --restore &
/usr/bin/razer-cli --restore &

Nothing works, I can't auto start this, I always have to type the cmd in a terminal when I log into X.

How can I autostart razer-cli --restore?

Here is the /.cache/razer-cli/razer-cli-settings.json. (changed to .txt to upload)

razer-cli-settings.txt

THANKS

[patch] Revise --dpi print & --poll print options

Before:

$ ~/.local/bin/razer-cli --dpi print --poll print
1200
1000
$ ~/.local/bin/razer-cli --poll print --dpi print
1200
1000
$ ~/.local/bin/razer-cli --poll print
1000
$ ~/.local/bin/razer-cli --dpi print
1200

After:

$ ~/.local/bin/razer-cli --dpi print --poll print
dpi: 1200
poll_rate: 1000
$ ~/.local/bin/razer-cli --poll print --dpi print
dpi: 1200
poll_rate: 1000
$ ~/.local/bin/razer-cli --poll print
1000
$ ~/.local/bin/razer-cli --dpi print
1200

Revised Functions:

def set_dpi(device_manager):
    # Iterate over each device and set DPI
    for device in device_manager.devices:
        # If -d argument is set, only set those devices
        if (args.device and device.name in args.device) or (not args.device):
            if (device.type != "mouse"):
                if args.verbose:
                    print("Device {} is not a mouse".format(device.name))
            elif args.dpi == "print":
                dpi = str(device.dpi)[1:-1].split(', ')
                if args.poll == "print":
                    if dpi[0] == dpi[1]:
                        print('dpi:',dpi[0])
                    else:
                        print('dpi:',dpi[0], dpi[1])
                else:
                    if dpi[0] == dpi[1]:
                        print(dpi[0])
                    else:
                        print(dpi[0], dpi[1])
            else:
                if args.verbose:
                    print("Setting DPI of device {} to {}".format(device.name,
                                                                  args.dpi))

                # Save used settings for this device to a file
                util.write_settings_to_file(device, dpi=args.dpi)

                # Actually set DPI
                args.dpi = args.dpi.split(',')
                if len(args.dpi) == 1:
                    args.dpi.append(int(args.dpi[0]))
                device.dpi = (int(args.dpi[0]), int(args.dpi[1]))


def set_poll_rate(device_manager):
    # Iterate over each device and set Polling Rate
    for device in device_manager.devices:
        # If -d argument is set, only set those devices
        if (args.device and device.name in args.device) or (not args.device):
            if device.has("poll_rate"):
                if args.poll == "print":
                    if args.dpi == "print":
                        print('poll_rate:',device.poll_rate)
                    else:
                        print(device.poll_rate)
                else:
                    if args.verbose:
                        print(
                            "Setting polling rate of device {} to {}".format(
                                device.name,
                                args.poll))

                    # Actually set Polling Rate
                    device.poll_rate = int(args.poll)
            else:
                print("Device does not support setting the polling rate")

-ll and -llh possible at once

#37 (comment)

Currently it's possible to do -ll and -llh at the same time:

razer-cli -ll -llh

Which outputs both the JSON format and the human readbale format.

Maybe some argparse options could be used to make this flag better. E.g. make it so it's actually the same flag but h adds an additional option to it.

ModuleNotFoundError: No module named '_dbus_bindings'

I have this error when trying to start razer-cli:

Traceback (most recent call last):
  File "/home/mpiase/.local/bin/razer-cli", line 5, in <module>
    from razer_cli.razer_cli.main import main
  File "/home/mpiase/.local/lib/python3.10/site-packages/razer_cli/razer_cli/main.py", line 12, in <module>
    from openrazer.client import DeviceManager
  File "/usr/lib/python3/dist-packages/openrazer/client/__init__.py", line 4, in <module>
    import dbus as _dbus
  File "/usr/lib/python3/dist-packages/dbus/__init__.py", line 73, in <module>
    import dbus.types as types
  File "/usr/lib/python3/dist-packages/dbus/types.py", line 8, in <module>
    from _dbus_bindings import (
ModuleNotFoundError: No module named '_dbus_bindings'

any hints? I am using "Ubuntu 20.04.6 LTS"

Packaging

In addition to the installation script, it'd be great to have some form of packaged app available, e.g. on PIP, the AUR, or as a deb. If anyone is on a specific distro and wants to create a package for it, feel free to open a PR.

Done:

Listing options cause an error and change device settings

Ideally, this should probably be two different bug reports and I should test if the other options reset the devices' settings but right now I don't feel like having to reboot into Windows to fix my device's settings after.

Basically, when executing razer-cli -l or razer-cli -ll my Viper Ultimate's DPI gets set to 1800 and the polling rate to 500 (according to razer-cli's output and I get the following error/output:

Found 2 Razer device(s)
Razer Viper Ultimate (Wireless):
type: mouse
DPI: (1800, 1800)
max DPI: 20000
polling rate: 500
battery:
charge: 75
charging: False
Traceback (most recent call last):
File "/usr/bin/razer-cli", line 33, in
sys.exit(load_entry_point('razer-cli==2.0.1', 'console_scripts', 'razer-cli')())
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/rc.py", line 73, in run
self.device_lister.list()
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/lister/device_lister.py", line 50, in list
device.get_low_battery_threshold(), '%')
File "/usr/lib/python3.9/site-packages/openrazer/client/devices/mice.py", line 281, in get_low_battery_threshold
return int(self._dbus_interfaces['power'].getLowBatteryThreshold())
File "/usr/lib/python3.9/site-packages/dbus/proxies.py", line 141, in call
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3.9/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/dbus/service.py", line 658, in _message_cb
(candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
File "/usr/lib/python3.9/site-packages/dbus/service.py", line 248, in _method_lookup
raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: getLowBatteryThreshold is not a valid method of interface razer.device.power

I have my mouse's dongle plugged into the dock and the dock plugged into the PC. I also have my Razer Kiyo webcam plugged into the PC but since the Kiyo doesn't work with openrazer, I am guessing the 2 devices razer-cli sees are the Mouse and Dock.

I am using razer-cli version 3.0.1 from GitHub and apparently even checking the version messes up the device's settings.

Show Brightness for mouse in -l output

Not all hardware has a generic brightness, but that is no excuse to not show what it is set to

def list_devices(device_manager):
    """
    List all connected Razer devices
    https://github.com/openrazer/openrazer/blob/master/examples/list_devices.py
    """

    print("Found {} Razer devices".format(len(device_manager.devices)))

    # Iterate over each device and pretty out some standard information about each
    for device in device_manager.devices:
        print("{}:".format(device.name))
        print("   type: {}".format(device.type))
        if (device.type == "mouse"):
            print("   DPI: {}".format(device.dpi))
            print("   max DPI: {}".format(device.max_dpi))
        if device.capabilities['poll_rate']:
            print("   polling rate: {}".format(device.poll_rate))
        if device.capabilities['brightness']:
            print("   brightness: {}".format(device.brightness))
        if device.capabilities['lighting_logo_brightness']:
            print("   brightness (logo): {}".format(device.fx.misc.logo.brightness))
        if device.capabilities['lighting_scroll_brightness']:
            print("   brightness (wheel): {}".format(device.fx.misc.scroll_wheel.brightness))
        if device.capabilities['lighting_left_brightness']:
            print("   brightness (left): {}".format(device.fx.misc.left.brightness))
        if device.capabilities['lighting_right_brightness']:
            print("   brightness (right): {}".format(device.fx.misc.right.brightness))
        print("   serial: {}".format(device.serial))
        print("   firmware version: {}".format(device.firmware_version))
        print("   driver version: {}".format(device.driver_version))

        device_effects = get_effects_of_device(device)
        print("   effects: {}".format(device_effects))

        if (args.list_devices_long):
            print("   capabilities: {}".format(device.capabilities))
        elif (args.list_devices_long_human):
            print("   capabilities:")
            for i in device.capabilities:
                print("      ", i, "=", device.capabilities[i])
    print()

To Do: add support to set brightness to individual parts of device

Effect option is very broken on mouse [Razer DeathAdder Elite]

$ for i in logo_breath_single logo_reactive logo_static scroll_breath_single scroll_reactive scroll_static breath_single multicolor ripple starlight_random starlight_single reactive;do echo test $i;.local/bin/razer-cli -e $i;done
test logo_breath_single
Effect is supported by device but not yet implemented.
Consider opening a PR:
https://github.com/LoLei/razer-x-color/pulls
test logo_reactive
Effect is supported by device but not yet implemented.
Consider opening a PR:
https://github.com/LoLei/razer-x-color/pulls
test logo_static
Effect is supported by device but not yet implemented.
Consider opening a PR:
https://github.com/LoLei/razer-x-color/pulls
test scroll_breath_single
Effect is supported by device but not yet implemented.
Consider opening a PR:
https://github.com/LoLei/razer-x-color/pulls
test scroll_reactive
Effect is supported by device but not yet implemented.
Consider opening a PR:
https://github.com/LoLei/razer-x-color/pulls
test scroll_static
Effect is supported by device but not yet implemented.
Consider opening a PR:
https://github.com/LoLei/razer-x-color/pulls
test breath_single
Setting device: Razer DeathAdder Elite to effect static
test multicolor
Setting device: Razer DeathAdder Elite to effect multicolor
test ripple
Setting device: Razer DeathAdder Elite to effect static
test starlight_random
Setting device: Razer DeathAdder Elite to effect static
test starlight_single
Setting device: Razer DeathAdder Elite to effect static
test reactive
Setting device: Razer DeathAdder Elite to effect static

I went to try to work on this, but not really sure where to start, figure it will probably need a full re-write, maybe you have some thoughts on it before i tackle it for the fun

JSON Decoder error

Hi,
From some days ago I have been receiving an error after running razer-cli -e multicolor,xpalette --sync.
The error that shows up is:

Traceback (most recent call last):
  File "/home/miguel/.local/bin/razer-cli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/miguel/.local/lib/python3.11/site-packages/razer_cli/razer_cli/main.py", line 30, in main
    rc.run()
  File "/home/miguel/.local/lib/python3.11/site-packages/razer_cli/razer_cli/rc.py", line 55, in run
    self.color_effect_handler.handle()
  File "/home/miguel/.local/lib/python3.11/site-packages/razer_cli/razer_cli/handler/color_effect_handler.py", line 31, in handle
    self.setter.set(effects=effects, color=color, zones=zones)
  File "/home/miguel/.local/lib/python3.11/site-packages/razer_cli/razer_cli/setter/color_effect_setter.py", line 21, in set
    self.set_effect_to_device(device, **kwargs)
  File "/home/miguel/.local/lib/python3.11/site-packages/razer_cli/razer_cli/setter/color_effect_setter.py", line 273, in set_effect_to_device
    util.write_settings_to_file(device, effects, color, zones=zones)
  File "/home/miguel/.local/lib/python3.11/site-packages/razer_cli/razer_cli/util.py", line 190, in write_settings_to_file
    json_data = json.load(file)
                ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I'm trying to debug the error without any success. I'm on Manjaro Linux x86_64 with kernel 6.5.0-1-MANJARO

Cheers,

DPI STAGES

Hi. Can you implement the possibility to disable the dpi stages?

How about static colorschemes?

Hi all,

Thank you for the awesome work.
(It appears to have some defect on my keeb, but I'll report once I'm sure there is nothing missing on my side.)

I thought it would be nice to add custom, key-wise static colorschemes. Would that fit within the project?
I took a stab myself at a zsh script to set static colorcodes.
The script is meant as a mere proof of concept, but I may have the time to re-write in python if that's something worthy of consideration for razer-cli.

Greetings.

Edit: pretty much a duplicate of #25 and #27.

[Patch] Process -l last

razor_cli.zip
Before:

$ .local/bin/razer-cli --dpi 900 --poll 500 -l
Found 1 Razer devices
Razer DeathAdder Elite:
   type: mouse
   DPI: (800, 800)
   max DPI: 16000
   polling rate: 125
   serial: 321848H04401822
   firmware version: v1.6
   driver version: 2.9.0
   effects: ['logo_breath_single', 'logo_reactive', 'logo_static', 'scroll_breath_single', 'scroll_reactive', 'scroll_static']

After:

$ .local/bin/razer-cli --dpi 500 --poll 500 -l
Found 1 Razer devices
Razer DeathAdder Elite:
   type: mouse
   DPI: (500, 500)
   max DPI: 16000
   polling rate: 500
   serial: 321848H04401822
   firmware version: v1.6
   driver version: 2.9.0
   effects: ['logo_breath_single', 'logo_reactive', 'logo_static', 'scroll_breath_single', 'scroll_reactive', 'scroll_static']

Listing options outputs an error

Basically, when executing razer-cli -l or razer-cli -ll I get the following error/output:

Found 2 Razer device(s)
Razer Viper Ultimate (Wireless):
type: mouse
DPI: (1800, 1800)
max DPI: 20000
polling rate: 500
battery:
charge: 75
charging: False
Traceback (most recent call last):
File "/usr/bin/razer-cli", line 33, in
sys.exit(load_entry_point('razer-cli==2.0.1', 'console_scripts', 'razer-cli')())
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/rc.py", line 73, in run
self.device_lister.list()
File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/lister/device_lister.py", line 50, in list
device.get_low_battery_threshold(), '%')
File "/usr/lib/python3.9/site-packages/openrazer/client/devices/mice.py", line 281, in get_low_battery_threshold
return int(self._dbus_interfaces['power'].getLowBatteryThreshold())
File "/usr/lib/python3.9/site-packages/dbus/proxies.py", line 141, in call
return self._connection.call_blocking(self._named_service,
File "/usr/lib/python3.9/site-packages/dbus/connection.py", line 652, in call_blocking
reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/dbus/service.py", line 658, in _message_cb
(candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
File "/usr/lib/python3.9/site-packages/dbus/service.py", line 248, in _method_lookup
raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: getLowBatteryThreshold is not a valid method of interface razer.device.power

I have my mouse's dongle plugged into the dock and the dock plugged into the PC. I also have my Razer Kiyo webcam plugged into the PC but since the Kiyo doesn't work with openrazer, I am guessing the 2 devices razer-cli sees are the Mouse and Dock.

I am using razer-cli version 2.0.1 from GitHub, installed by:

git clone https://github.com/LoLei/razer-cli.git
cd razer-cli
sudo pip install .

Brightness

Check if brightness works. Forgot if I implemented it. Workaround right now is reactive.

Effect is supported by device but not yet implemented - Spectrum

it would be great to get the spectrum effect support added to the tool

razer-cli -l
Found 2 Razer devices
Razer Ornata Chroma:
type: keyboard
brightness: 75.0
serial: UNKWN000000002744
firmware version: v1.0
driver version: 2.9.0
effects: ['breath_dual', 'breath_random', 'breath_single', 'reactive', 'ripple', 'ripple_random', 'spectrum', 'starlight_dual', 'starlight_random', 'static', 'wave']
Razer Naga Hex V2:
type: mouse
DPI: (800, 800)
max DPI: 16000
polling rate: 500
brightness: 75.0
brightness (logo): 75.0
brightness (wheel): 75.0
serial: UNKWN000000003776
firmware version: v1.0
driver version: 2.9.0
effects: ['breath_dual', 'breath_random', 'breath_single', 'logo_breath_single', 'logo_reactive', 'logo_static', 'reactive', 'scroll_breath_single', 'scroll_reactive', 'scroll_static', 'spectrum', 'static']

razer-cli --sync -e spectrum
creating path and file
Adding new settings entry
Effect is supported by device but not yet implemented.
Consider opening a PR:
https://github.com/LoLei/razer-x-color/pulls
Adding new settings entry
Effect is supported by device but not yet implemented.
Consider opening a PR:
https://github.com/LoLei/razer-x-color/pulls

Thanks
Oliver

Drop sys from argument_parser.py (optimization patch)

Refracting patch eliminates need for import sys in this file, if you really want to use sys.exit(1) you can do so in place of return False in razer_cli.py

diff -Naur --exclude __pycache__ razer-cli-master/razer_cli/razer_cli/parsing/argument_parser.py razer-cli/razer_cli/parsing/argument_parser.py
--- razer-cli-master/razer_cli/razer_cli/parsing/argument_parser.py	2021-02-12 09:36:43.000000000 -0500
+++ razer-cli/razer_cli/parsing/argument_parser.py	2021-02-12 10:45:54.975282604 -0500
@@ -1,5 +1,4 @@
 import argparse
-import sys
 from typing import List
 
 
@@ -83,6 +82,6 @@
 
     if len(input_args) < 1:
         parser.print_help()
-        sys.exit(1)
+        return False
 
     return parser.parse_args(input_args)
diff -Naur --exclude __pycache__ razer-cli-master/razer_cli/razer_cli/razer_cli.py razer-cli/razer_cli/razer_cli.py
--- razer-cli-master/razer_cli/razer_cli/razer_cli.py	2021-02-12 09:36:43.000000000 -0500
+++ razer-cli/razer_cli/razer_cli.py	2021-02-12 10:41:45.911775225 -0500
@@ -89,6 +89,8 @@
     """ Main entry point of the app """
     global args
     args = read_args(sys.argv[1:])
+    if not args:
+        return False
 
     if args.manual is not None:
         return util.print_manual(args.manual)

[Patch] Improve readability of device capabilities

https://github.com/LoLei/razer-cli/blob/master/razer_cli/razer_cli.py#L119-L120
Code Changes:

        if (args.list_devices_long):
            #print("   capabilities: {}".format(device.capabilities))
            print("   capabilities:")
            for i in device.capabilities:
                 print("      ",i,"=",device.capabilities[i])

Before:

$ .local/bin/razer-cli -ll
Found 1 Razer devices
Razer DeathAdder Elite:
   type: mouse
   DPI: (1100, 1100)
   max DPI: 16000
   polling rate: 1000
   serial: 321848H04401822
   firmware version: v1.6
   driver version: 2.9.0
   effects: ['logo_breath_single', 'logo_reactive', 'logo_static', 'scroll_breath_single', 'scroll_reactive', 'scroll_static']
   capabilities: {'name': True, 'type': True, 'firmware_version': True, 'serial': True, 'brightness': False, 'macro_logic': False, 'keyboard_layout': False, 'lighting': True, 'lighting_breath_single': False, 'lighting_breath_dual': False, 'lighting_breath_triple': False, 'lighting_breath_random': False, 'lighting_wave': False, 'lighting_reactive': False, 'lighting_none': False, 'lighting_spectrum': False, 'lighting_static': False, 'lighting_starlight_single': False, 'lighting_starlight_dual': False, 'lighting_starlight_random': False, 'lighting_ripple': False, 'lighting_ripple_random': False, 'lighting_pulsate': False, 'lighting_led_matrix': True, 'lighting_led_single': False, 'lighting_logo': True, 'lighting_logo_active': False, 'lighting_logo_blinking': False, 'lighting_logo_brightness': True, 'lighting_logo_pulsate': False, 'lighting_logo_spectrum': True, 'lighting_logo_static': True, 'lighting_logo_none': True, 'lighting_logo_reactive': True, 'lighting_logo_wave': False, 'lighting_logo_breath_single': True, 'lighting_logo_breath_dual': True, 'lighting_logo_breath_random': True, 'lighting_scroll': True, 'lighting_scroll_active': False, 'lighting_scroll_blinking': False, 'lighting_scroll_brightness': True, 'lighting_scroll_pulsate': False, 'lighting_scroll_spectrum': True, 'lighting_scroll_static': True, 'lighting_scroll_none': True, 'lighting_scroll_reactive': True, 'lighting_scroll_wave': False, 'lighting_scroll_breath_single': True, 'lighting_scroll_breath_dual': True, 'lighting_scroll_breath_random': True, 'lighting_left': False, 'lighting_left_active': False, 'lighting_left_brightness': False, 'lighting_left_spectrum': False, 'lighting_left_static': False, 'lighting_left_none': False, 'lighting_left_reactive': False, 'lighting_left_wave': False, 'lighting_left_breath_single': False, 'lighting_left_breath_dual': False, 'lighting_left_breath_random': False, 'lighting_right': False, 'lighting_right_active': False, 'lighting_right_brightness': False, 'lighting_right_spectrum': False, 'lighting_right_static': False, 'lighting_right_none': False, 'lighting_right_reactive': False, 'lighting_right_wave': False, 'lighting_right_breath_single': False, 'lighting_right_breath_dual': False, 'lighting_right_breath_random': False, 'lighting_backlight': False, 'lighting_backlight_active': False, 'lighting_profile_led_red': False, 'lighting_profile_led_green': False, 'lighting_profile_led_blue': False, 'poll_rate': True, 'dpi': True, 'available_dpi': False, 'battery': False}

After:

$ .local/bin/razer-cli -ll
Found 1 Razer devices
Razer DeathAdder Elite:
   type: mouse
   DPI: (1100, 1100)
   max DPI: 16000
   polling rate: 1000
   serial: 321848H04401822
   firmware version: v1.6
   driver version: 2.9.0
   effects: ['logo_breath_single', 'logo_reactive', 'logo_static', 'scroll_breath_single', 'scroll_reactive', 'scroll_static']
   capabilities: 
	 name = True
	 type = True
	 firmware_version = True
	 serial = True
	 brightness = False
	 macro_logic = False
	 keyboard_layout = False
	 lighting = True
	 lighting_breath_single = False
	 lighting_breath_dual = False
	 lighting_breath_triple = False
	 lighting_breath_random = False
	 lighting_wave = False
	 lighting_reactive = False
	 lighting_none = False
	 lighting_spectrum = False
	 lighting_static = False
	 lighting_starlight_single = False
	 lighting_starlight_dual = False
	 lighting_starlight_random = False
	 lighting_ripple = False
	 lighting_ripple_random = False
	 lighting_pulsate = False
	 lighting_led_matrix = True
	 lighting_led_single = False
	 lighting_logo = True
	 lighting_logo_active = False
	 lighting_logo_blinking = False
	 lighting_logo_brightness = True
	 lighting_logo_pulsate = False
	 lighting_logo_spectrum = True
	 lighting_logo_static = True
	 lighting_logo_none = True
	 lighting_logo_reactive = True
	 lighting_logo_wave = False
	 lighting_logo_breath_single = True
	 lighting_logo_breath_dual = True
	 lighting_logo_breath_random = True
	 lighting_scroll = True
	 lighting_scroll_active = False
	 lighting_scroll_blinking = False
	 lighting_scroll_brightness = True
	 lighting_scroll_pulsate = False
	 lighting_scroll_spectrum = True
	 lighting_scroll_static = True
	 lighting_scroll_none = True
	 lighting_scroll_reactive = True
	 lighting_scroll_wave = False
	 lighting_scroll_breath_single = True
	 lighting_scroll_breath_dual = True
	 lighting_scroll_breath_random = True
	 lighting_left = False
	 lighting_left_active = False
	 lighting_left_brightness = False
	 lighting_left_spectrum = False
	 lighting_left_static = False
	 lighting_left_none = False
	 lighting_left_reactive = False
	 lighting_left_wave = False
	 lighting_left_breath_single = False
	 lighting_left_breath_dual = False
	 lighting_left_breath_random = False
	 lighting_right = False
	 lighting_right_active = False
	 lighting_right_brightness = False
	 lighting_right_spectrum = False
	 lighting_right_static = False
	 lighting_right_none = False
	 lighting_right_reactive = False
	 lighting_right_wave = False
	 lighting_right_breath_single = False
	 lighting_right_breath_dual = False
	 lighting_right_breath_random = False
	 lighting_backlight = False
	 lighting_backlight_active = False
	 lighting_profile_led_red = False
	 lighting_profile_led_green = False
	 lighting_profile_led_blue = False
	 poll_rate = True
	 dpi = True
	 available_dpi = False
	 battery = False

maybe this should be a -llh option, not sure if just dumping the JSON as a string is for scripting or not

Cannot list devices due to getLowBatteryThreshold not being a valid method

[llipovac@llipovac-DT Downloads]$ razer-cli -l
Found 2 Razer device(s)
Razer Basilisk Ultimate (Receiver):
type: mouse
DPI: (2500, 2500)
max DPI: 20000
polling rate: 500
battery:
charge: 97
charging: False
Traceback (most recent call last):
File "/home/llipovac/.local/bin/razer-cli", line 8, in
sys.exit(main())
^^^^^^
File "/home/llipovac/.local/lib/python3.11/site-packages/razer_cli/razer_cli/main.py", line 30, in main
rc.run()
File "/home/llipovac/.local/lib/python3.11/site-packages/razer_cli/razer_cli/rc.py", line 73, in run
self.device_lister.list()
File "/home/llipovac/.local/lib/python3.11/site-packages/razer_cli/razer_cli/lister/device_lister.py", line 50, in list
device.get_low_battery_threshold(), '%')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/openrazer/client/devices/init.py", line 494, in get_low_battery_threshold
return int(self._dbus_interfaces['power'].getLowBatteryThreshold())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/proxies.py", line 141, in call
return self._connection.call_blocking(self._named_service,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/connection.py", line 634, in call_blocking
reply_message = self.send_message_with_reply_and_block(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Traceback (most recent call last):
File "/usr/lib64/python3.11/site-packages/dbus/service.py", line 659, in _message_cb
(candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/dbus/service.py", line 249, in _method_lookup
raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
dbus.exceptions.UnknownMethodException: org.freedesktop.DBus.Error.UnknownMethod: Unknown method: getLowBatteryThreshold is not a valid method of interface razer.device.power

Wave effect speed controll missing

I wanted to mess around with the speed of the wave effect. (I wanted to slow it down a bit so it's not that 'flashy'). But it's not an option, as it is on the windows version of synapse.
Then I wanted to edit the files responsible for the effects, but I couldn't find it out how to do it (& where to find it) (it's a skill issue of my side I guess).
Can you add the feature of changing the speed of the wave effect to the app, or give advice how I could do it on my own?

Reactive effect for Razer Mousepad (Firefly) doesn't work

The Windows Razer app (which I used to use back when I was soy) makes the mousepad flash reactively when I click my mouse. However, even though the 'reactive' effect appears to be supported by this program for my mousepad, it won't do anything - my mousepad stays dark. Is this a known issue?

openrazer.client.DaemonNotFound: Could not connect to daemon

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/dbus/bus.py", line 177, in activate_name_owner
    return self.get_name_owner(bus_name)
  File "/usr/lib/python3.9/site-packages/dbus/bus.py", line 361, in get_name_owner
    return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
  File "/usr/lib/python3.9/site-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.razer': no such name

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/openrazer/client/__init__.py", line 22, in __init__
    self._dbus = session_bus.get_object("org.razer", "/org/razer")
  File "/usr/lib/python3.9/site-packages/dbus/bus.py", line 241, in get_object
    return self.ProxyObjectClass(self, bus_name, object_path,
  File "/usr/lib/python3.9/site-packages/dbus/proxies.py", line 250, in __init__
    self._named_service = conn.activate_name_owner(bus_name)
  File "/usr/lib/python3.9/site-packages/dbus/bus.py", line 182, in activate_name_owner
    self.start_service_by_name(bus_name)
  File "/usr/lib/python3.9/site-packages/dbus/bus.py", line 277, in start_service_by_name
    return (True, self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
  File "/usr/lib/python3.9/site-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/razer-cli", line 33, in <module>
    sys.exit(load_entry_point('razer-cli==2.0.1', 'console_scripts', 'razer-cli')())
  File "/usr/lib/python3.9/site-packages/razer_cli-2.0.1-py3.9.egg/razer_cli/razer_cli/main.py", line 27, in main
    device_manager = DeviceManager()
  File "/usr/lib/python3.9/site-packages/openrazer/client/__init__.py", line 24, in __init__
    raise DaemonNotFound("Could not connect to daemon")
openrazer.client.DaemonNotFound: Could not connect to daemon

Im on Artix (Arch with runit)

Add Support for Polling Rate (with patch)

razer_cli.zip
Change Log:

  • [New] Set Polling Rate (razer-cli --poll 125|500|1000)
  • [New] Read Polling Rate (razer-cli --poll print)
  • [New] Show Polling Rate in device list (razer-cli -l)
  • [New] Print DPI (razer-cli --dpi print)
  • [Change] Support different X/Y DPI settings
  • [Fix] Do not mess with RGB stuff if it is not being touched (minor performance upgrade)

Sorry the patch includes other stuff, i do not bother with version control

Installing razer-cli requires --break-system-packages flag

When installing razer-cli, it appears that neither venv, conda, nor pipx installs are supported, as they do not include the system-managed version of the openrazer package. That then requires installing razer-cli into the system-wide site-packages folder using pip, but as of PEP 668 (June 2022), that requires using the --break-system-packages flag when calling pip.

Needs testing on more devices

If anyone has Razer devices, keyboards, mice, headsets, etc., I'd appreciate it if you could test if everything works for you, and if not, tell me, or open a PR yourself!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.