Giter Club home page Giter Club logo

l5p-kbl's Introduction

Lenovo Legion 5 Pro 2021 Linux RGB Keyboard Light Controller

Lenovo Legion 5 Pro 2021 Linux RGB Keyboard Light Controller

This util allows to drive RGB keyboard light on Lenovo Legion 5 Pro 2021 Laptop

Requirements

  • pyusb

Install

Regular python

git clone https://github.com/imShara/l5p-kbl
cd l5p-kbl
python3 -m venv env
source ./env/bin/activate
pip install -r requirements.txt
python3 l5p-kbl.py --help

Archlinux

sudo pacman -Sy python-pyusb
git clone https://github.com/imShara/l5p-kbl
cd l5p-kbl
python l5p-kbl.py --help

Unprivileged usage

Add udev rule if you want to swith light as unprivileged user

# /etc/udev/rules.d/99-kblight.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="c965", MODE="0666"

Reload rules

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

Usage

Colors

I'ts possible to set color for 4 sections of keyboard separately like COLOR COLOR COLOR COLOR, but you can set single color for whole keyboard with just COLOR. Last color will be repeated for other sections.

HEX

HEX colors should be 6-digit base 16 input like ffffff

RGB

RGB colors should be 0-255 decimal values for each component, separated by comma like 255,0,127

HSV

HSV colors should be 0.0-1.0 float values for hue, saturation, value, separated by comma like 0.0,1.0,0.25

Light effect

statiс

Static color

usage: l5p_kbl.py static [-h] [--brightness {1,2}] colors [colors ...]

positional arguments:
  colors              Colors of sections

optional arguments:
  -h, --help          show this help message and exit
  --brightness {1,2}  Light brightness

Turn 100% red

./l5p_kbl.py static ff0000

At full brightness, turn 100% red for 1 section, 100% green for 2 section, 100% blue for 3 section an 100% white for 4 section

./l5p_kbl.py static ff0000 00ff00 0000ff ffffff --brightness 2

Dimmed warm orange like wire heater. With HSV color input.

./l5p_kbl.py static 0.02,1,0.2

breath

Fade light in and out

usage: l5p_kbl.py breath [-h] [--brightness {1,2}] [--speed {1,2,3,4}] colors [colors ...]

positional arguments:
  colors              Colors of sections

optional arguments:
  -h, --help          show this help message and exit
  --brightness {1,2}  Light brightness
  --speed {1,2,3,4}   Animation speed

Fast white blink at full brightness

./l5p_kbl.py breath ffffff --speed 4 --brightness 2

hue

Transition across hue circle. You can't set custom colors here.

usage: l5p_kbl.py hue [-h] [--brightness {1,2}] [--speed {1,2,3,4}]

optional arguments:
  -h, --help          show this help message and exit
  --brightness {1,2}  Light brightness
  --speed {1,2,3,4}   Animation speed

Rotate HUE slowly

./l5p_kbl.py hue --speed 1

wave

Rainbow wawe effect. Wow. Cool. Useles.

usage: l5p_kbl.py wave [-h] [--brightness {1,2}] [--speed {1,2,3,4}] {ltr,rtl}

positional arguments:
  {ltr,rtl}           Direction of wave

optional arguments:
  -h, --help          show this help message and exit
  --brightness {1,2}  Light brightness
  --speed {1,2,3,4}   Animation speed

Wheeee, left to right

./l5p_kbl.py wave ltr

Pew-pew-pew, right to left

./l5p_kbl.py wave rtl --speed 4

off

Turn light off. Nuff said.

usage: l5p_kbl.py off [-h]

optional arguments:
  -h, --help  show this help message and exit

Recommendations

Set Super+Space keystroke to turn light on and turn it off with single fn+Space press

TODO

  • Minimum viable product
  • HSV color input
  • Create setupscript
  • Create Archlinux AUR package
  • Advanced usage:
    • Swithc light depend on keyboard layout
    • Switch light depend on terminal rights
    • Music light accompaniment

Payload description

Device vendor = 048d, product = c965

HEADER ........... cc
HEADER ........... 16
EFFECT ........... 01 - static / 03 - breath / 04 - wave / 06 - hue
SPEED ............ 01 / 02 / 03 / 04
BRIGHTNESS ....... 01 / 02
RED SECTION 1 .... 00-ff
GREEN SECTION 1 .. 00-ff
BLUE SECTION 1 ... 00-ff
RED SECTION 2 .... 00-ff
GREEN SECTION 2 .. 00-ff
BLUE SECTION 2 ... 00-ff
RED SECTION 3 .... 00-ff
GREEN SECTION 3 .. 00-ff
BLUE SECTION 3 ... 00-ff
RED SECTION 4 .... 00-ff
GREEN SECTION 4 .. 00-ff
BLUE SECTION 4 ... 00-ff
UNUSED ........... 00
WAVE MODE RTL .... 00 / 01
WAVE MODE LTR .... 00 / 01
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00
UNUSED ........... 00

l5p-kbl's People

Contributors

imshara 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

Watchers

 avatar  avatar  avatar  avatar  avatar

l5p-kbl's Issues

Seeking contact

Hello, I'm very sorry I'm contacting you through an issue on GitHub, but I was unable to find another way to contact you. I recently got a Lenovo Legion 5 Pro, and I'm running Linux on it. Are you also running Linux or Windows? If Linux, did you manage to get your 165Hz screen refresh rate to work? You can contact me though email at [email protected].

Thanks!!

Getting error on use

Trying to use the script on a Legion 5 15ARH05H (AMD 4800h + RTX 2060)
Arch Linux. Assuming there's a driver I need to load?
Getting this error.

./l5p_kbl.py static ff0000
Traceback (most recent call last):
  File ".../l5p-kbl/./l5p_kbl.py", line 240, in <module>
    controller = LedController()
  File ".../l5p-kbl/./l5p_kbl.py", line 63, in __init__
    raise ValueError("Light device not found")
ValueError: Light device not found

Not working

Tried to run the script, after adjusting vendor. Then the script goes without error, but makes absolutely no change to the lighting. I can use only the preset modes and not customize them (same goes for windows 11 and Lenovo Vantage). Any solution to this?

Invalid syntax

First of all, thank you for making this tool! I would love to get it to work.

But it errors when I run it. Here is an example

(env) [root@legion l5p-kbl] ./l5p_kbl.py breath ffffff --speed 4 --brightness 2
File "./l5p_kbl.py", line 118
f"Invalid RGB color model: {color}"
^
SyntaxError: invalid syntax

Support for Legion 5 15 15ARH05

The product ID is C100 but changing the value to that and running the script freezes my keyboard.
What kind of information would I need to provide in order to have support for this device?
The keyboard and lighting settings are exactly the same on the Lenovo Vantage software, so I would assume it's just the RGB values/formats that are different?
Thanks.

syntax error in readme.md

README.md

All of the install command lists, have an error.
the file l5p_kbl.py is wrote with a dash in the help command. I have attached a corrected readme file

[SOLVED] adding support for Legion 5i Pro 2022

is there anything I can provide for adding support for L5P 2022?
right now I am getting this error:

Traceback (most recent call last):
  File "/usr/bin/l5p-kbl", line 240, in <module>
    controller = LedController()
  File "/usr/bin/l5p-kbl", line 63, in __init__
    raise ValueError("Light device not found")
ValueError: Light device not found

my lsusb output:

Bus 004 Device 002: ID 05e3:0620 Genesys Logic, Inc. GL3523 Hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 005: ID 048d:c975 Integrated Technology Express, Inc. ITE Device(8295)
Bus 003 Device 003: ID 048d:c102 Integrated Technology Express, Inc. ITE Device(8910)
Bus 003 Device 010: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
Bus 003 Device 002: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 003 Device 006: ID 8087:0033 Intel Corp. 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

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.