4JX / L5P-Keyboard-RGB

Cross platform software to control the RGB/lighting of the 4 zone keyboard included in the 2020, 2021, 2022 and 2023 lineup of the Lenovo Legion laptops. Works on Windows and Linux.
GNU General Public License v3.0
330 stars 41 forks source link
effects egui keyboard legion lenovo lenovo-legion rust
logo

Legion RGB Control

Latest Version Build Status Support Server

logo [![Donate](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/4JX/donate)

Index

Download

⚠️ Use at your own risk, the developer is not responsible for any damages that may arise as a result of using this program.

Builds will be periodically uploaded to the releases tab.

You may also download pre-compiled versions from here (requires github account) by clicking the latest entry with a ✅ and going under the "artifacts" section.

Available effects

All stock effects: Static, Breath, Smooth, LeftWave, RightWave.

Custom effects:

Creating your own effects

The best way to add a new effect is to directly edit the source code, as it allows the most flexibility. You can however also use the built-in feature to make basic effects.

At a glance

{
 "effect_steps": [
  {"rgb_array": [0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0], "step_type": "Set", "brightness": 1, "steps": 100, "delay_between_steps": 100, "sleep": 100},
  {"rgb_array": [0, 100, 0, 0, 0, 200, 0, 0, 200, 200, 0, 0], "step_type": "Transition", "brightness": 1, "steps": 100, "delay_between_steps": 100, "sleep": 100}
 ],
 "should_loop": true
}

File sections

Usage

Note: By default, on Linux you will have to run the program with root privileges, however, you can remedy this by adding the following udev rule (in a path similar to /etc/udev/rules.d/99-kblight.rules):

# Pro Models
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c995", MODE="0666"
# Regular Legions
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c994", MODE="0666"
# LOQ Models
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c993", MODE="0666"
# Pro Models
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c985", MODE="0666"
# Regular Legions
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c984", MODE="0666"
# LOQ Models
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c983", MODE="0666"
# Regular legions
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c975", MODE="0666"

# Ideapad models
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c973", MODE="0666"
# Regular legions
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c965", MODE="0666"

# Ideapad models
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c963", MODE="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c955", MODE="0666"

And then reloading the rules:

sudo udevadm control --reload-rules && sudo udevadm trigger

With GUI

Execute the file by double-clicking on it. You may pass extra startup options via the CLI by also specifying the --gui flag.

Configuration for this mode is saved by default on the folder the program was executed in a file called settings.json, you can override this location by setting the LEGION_KEYBOARD_CONFIG environment variable.

Via the command line

Usage:

legion-kb-rgb [OPTIONS] [SUBCOMMAND]

Examples:

legion-kb-rgb --help
legion-kb-rgb set -e Static -c 255,0,0,255,0,0,255,0,0,255,0,0
legion-kb-rgb set -e SmoothWave -s 4 -b 2 -d Left

Compatibility

This program has been tested to work on:

"How about X model"

Building from source

Prerequisites

Ubuntu

sudo apt-get install -y libclang-dev libxcb-shm0-dev libusb-1.0-0-dev libx11-dev nasm libdbus-1-dev libudev-dev libxcb-randr0-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libxi-dev libxtst-dev

Using cargo-make

Works on both Windows and Linux.

cargo install cargo-make
git clone https://github.com/4JX/L5P-Keyboard-RGB.git
cd L5P-Keyboard-RGB/
cargo make build-release

Building manually

Windows:

vcpkg update && vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static

Linux:

vcpkg update && vcpkg install libvpx libyuv
git clone https://github.com/4JX/L5P-Keyboard-RGB.git
cd L5P-Keyboard-RGB/
cargo build --release

Crashes, freezes, etc

I cannot guarantee this solution will work for anyone but myself. That being said feel free to open an issue if you encounter any of these problems on the issues tab.


Thanks to legendk95#0574 (272711294338072577) over at discord for initially reverse engineering the way to talk to the keyboard.