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
cherry cli evision keyboard keys linux mac rgb rust sonix utility windows

Cherry RGB Keyboard Library

Crates.io Docs.rs GitHub release CI

Compatibility

To see which devices are tested take a look at the Compatibility Table.

Contributing

See CONTRIBUTING Guidelines.

Features

Done

Missing

Library

Please see Docs.rs

UHID Service

To workaround the issue of "slow keypresses", @felfert implemented a userspace HID driver/service and a corresponding CLI.

Check out UHID Driver documentation on how to install and use it.

CLI

Documentation for the CLI is now generated in separate files:

Alternative CLI and service for Linux

Usage examples and remarks

Set LED animation

./cherryrgb_cli --brightness medium animation wave fast 00ff00

Unofficial animation modes

Please note, that the following modes are unofficial and therefore are not guaranteed to work properly:

Set custom key colors

./cherryrgb_cli --brightness full custom-colors ff00ff 0000ff

Color profile file

In addition to specifying custom colors via arguments you can create your custom color profiles in a separate file and pass the path of the file as an argument.

Color profile file structure:

{
    "0": "ff00ff",
    "1": "fffff",
    "45": "00ff00",
    "31": "ff0000"
}

A profile file is a JSON file that contains a root object and a key value pair for each key. Both key and value MUST be strings. The JSON parser now has ben changed slightly to allow for 2 normally unsupported variations:

Example:

./cherryrgb_cli --brightness full color-profile-file {FILE PATH}

Example bash script, demonstrating the new --keep-existing-colors feature:

#!/bin/bash
cherryrgb_cli color-profile-file examples/static_rainbow.json
for i in 1 2 3 4 5 ; do
    sleep 0.5
    cherryrgb_cli color-profile-file -k examples/white_f12.json
    sleep 0.5
    cherryrgb_cli color-profile-file -k examples/red_f12.json
done

Note: Because existing colors cannot be read from the keyboard, they are stored in a local cache after setting them. Therfore, in order to use this feature, the command color-profile-file has to be invoked at least once before.

Build from source

Dependencies

Clone & Build

git clone https://github.com/skraus-dev/cherryrgb-rs.git
cd cherryrgb-rs
cargo build
cargo xtask all

For a complete build on Linux (including service and alternative cli), you can do the following:

Now you can run the binary from ./target/debug/cherryrgb_cli

Generated documentation and shell completion scripts

When running the above command cargo xtask all, a directory hierarchy is generated:

target/generated/docs/
                 man/
                 completions\

which contain:

Install through package manager

Troubleshooting

Keyboard device is not discovered aka. "Keyboard not found" in normal user context

If the interaction with the keyboard is fine as root-user, you need to configure udev to adjust the ownership of the device handle, so a regular user can access it.

The repository contains an example udev rule file udev/99-cherryrgb.rules.

You might want to adjust it to only handle your specific product id (check via lsusb).

In the following example we assume your product id is 0x00dd.

  1. (optional) Change ATTR{idProduct}=="*" to ATTR{idProduct}=="00dd".

  2. Copy the file to the correct location: cp 99-cherryrgb.rules /etc/udev/rules.d/ (as a privileged user)

  3. Finally, reload the udev rules via udevadm control --reload and apply them using udevadm trigger or by re-plugging your keyboard.

Keyboard events are processed very slow after setting LEDs

This is a known issue in the keyboard firmware. It is mentioned here: https://bbs.archlinux.org/viewtopic.php?id=267365

Disclaimer

Use at your own risk. This project is not affiliated or endorsed by Cherry GmbH.

Changelog

v0.2.8 - 18/06/2023

v0.2.7 - 03/06/2023

v0.2.6 - 18/05/2023

v0.2.5 - 17/05/2023

v0.2.4 - 25/04/2023

v0.2.3 - 15/04/2023

v0.2.2 - 29/03/2023

v0.2.1 - 08/08/2021

v0.2.0 - 29/07/2021

v0.1.2 - 28/07/2021

v0.1.1 - 28/07/2021

v0.1.0 - 24/07/2021