Lenovo Legion 5 Pro 2021 Linux RGB Keyboard Light Controller

Related tags

Hardware l5p-kbl
Overview

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
python -m venv env
source ./env/bin/activate
pip install -r requirements.txt
python 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/10-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
Comments
  • Seeking contact

    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!!

    opened by DJsushi 13
  • Invalid syntax

    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

    question 
    opened by gnomiik 4
  • syntax error in readme.md

    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

    opened by ravensdark 0
  • Support for Legion 5 15 15ARH05

    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.

    opened by lvctr 3
  • Getting error on use

    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
    
    opened by robojerk 9
Owner
null
Hook and simulate global keyboard events on Windows and Linux.

keyboard Take full control of your keyboard with this small Python library. Hook global events, register hotkeys, simulate key presses and much more.

BoppreH 3.2k Dec 30, 2022
I made this so I can control my Tapo L510 light bulb and Govee H6159 light strip using the PyP100 module and the Govee public API

TAPO-And-Govee-Controller I made this so I can control my Tapo L510 light bulb and Govee H6159 light strip using the PyP100 module and the Govee publi

James Westhead 0 Nov 23, 2021
Red Light Green Light Robot

Red Light Green Light Robot The primary problem addressed by our project is robotic follower behavior i.e. maintaining distance from a moving target.

Will Romano 2 Nov 20, 2021
Python module for controlling Broadlink RM2/3 (Pro) remote controls, A1 sensor platforms and SP2/3 smartplugs

Python module for controlling Broadlink RM2/3 (Pro) remote controls, A1 sensor platforms and SP2/3 smartplugs

Matthew Garrett 1.2k Jan 4, 2023
LedFx is a network based LED effect controller with support for advanced real-time audio effects

Welcome to LedFx ✨ -Making music come alive! LedFx website: https://ledfx.app/ What is LedFx? What LedFx offers is the ability to take audio input, an

null 786 Jan 2, 2023
It is a serial communicator(controller, receiver...), communicate with sensor LP20 which is a laser ranger.

Intro It is a serial communicator(controller, receiver...), communicate with sensor LP20 which is a laser ranger. Its datasheet is contained in this r

null 3 Sep 19, 2022
BoneIO is a compact IO controller for home automation.

Project description BoneIO is a compact IO controller for home automation. Main features of this controller are Compact size (27x11x6)cm - 15 DIN modu

Maciej Krasuski 120 Nov 30, 2022
Control DJI Tello with Raspberry Pi and PS4 Controller

Control-DJI-Tello-with-Raspberry-Pi-and-PS4-Controller Demo of this project see

MohammadReza Sharifi 24 Aug 11, 2022
Christmasvillage-rpi - Raspberry Pi relay controller for ChristmasVillage.io

ChristmasVillage.io Relay Controller Links ChristmasVillage.io - Live Stream & Controls Youtube Instagram About This repository controls the light rel

Grant Windes 2 Feb 15, 2022
A simple portable USB MIDI controller based on Raspberry-PI Pico and a 16-button keypad, written in Circuit Python

RPI-Pico-16-BTn-MIDI-Controller-using-CircuitPython A simple portable USB MIDI controller based on Raspberry-PI Pico, written in Circuit Python. Link

Rounak Dutta 3 Dec 4, 2022
A module for cross-platform control of the mouse and keyboard in python that is simple to install and use.

PyUserInput PyUserInput is a group project so we've moved the project over to a group organization: https://github.com/PyUserInput/PyUserInput . That

Paul Barton 1k Dec 27, 2022
A custom mechanical keyboard inspired by the CFTKB Mysterium

Env-KB A custom mechanical keyboard inspired by the CFTKB Mysterium Build Guide and Parts List What is to do? Right now for the first 5 PCBs I have, i

EnviousData 203 Jan 4, 2023
KIRI - Keyboard Interception, Remapping, and Injection using Raspberry Pi as an HID Proxy.

KIRI - Keyboard Interception, Remapping and Injection using Raspberry Pi as a HID Proxy. Near limitless abilities for a keyboard warrior. Features Sim

Viggo Falster 10 Dec 23, 2022
This allows you to record keyboard and mouse input, and play it back using pynput.

Record and Play with Python! This allows you to record keyboard and mouse input, and play it back (with looping) using pynput. It allows for automatio

George Jensen 45 Jan 2, 2023
This is a Virtual Keyboard which is simple yet effective to use.

Virtual-Keyboard This is a Virtual KeyBoard which can track finger movements and lets you type anywhere ranging from notepad to even web browsers. It

Jehan Patel 3 Oct 1, 2021
Make your MacOS keyboard brightness fade in and out

Make your MacOS keyboard brightness fade in and out. (It's working depends on the Kbrightness file, which only works for <2015 Macs, so this will only work on <2015 Macs.)

null 1 Dec 16, 2021
PyLog - Simple keylogger that uses pynput to listen to keyboard input.

Simple keylogger that uses pynput to listen to keyboard input. Outputs to a text file and the terminal. Press the escape key to stop.

null 1 Dec 29, 2021
Keystroke logging, often referred to as keylogging or keyboard capturing

Keystroke logging, often referred to as keylogging or keyboard capturing, is the action of recording the keys struck on a keyboard, typically covertly, so that a person using the keyboard is unaware that their actions are being monitored.

Bhumika R 2 Jan 11, 2022
A Python class for controlling the Pimoroni RGB Keypad for Raspberry Pi Pico

rgbkeypad A Python class for controlling the Pimoroni RGB Keypad for the Raspberry Pi Pico. Compatible with MicroPython and CircuitPython. keypad = RG

Martin O'Hanlon 43 Nov 11, 2022