Lenovo Legion 5 Pro 2021 Linux RGB Keyboard Light Controller

Related tags

Hardwarel5p-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
Python apps to assist with Gas Blending

Welcome to DiveTools Gas Blending This tool is for testing and educational use. It is not intended to confirm the mix of breathing gases. If this tool

Tucker 7 Sep 18, 2022
Example Python code for building RPi-controlled robotic systems

RPi Example Code Example Python code for building RPi-controlled robotic systems These python files have been compiled / developed by the Neurobionics

Elliott Rouse 2 Feb 04, 2022
Scripts for measuring and displaying thermal behavior on Voron 3D printers

Thermal Profiling Measuring gantry deflection and frame expansion This script runs a series of defined homing and probing routines designed to charact

Jon Sanders 30 Nov 27, 2022
View your medication from Medisafe Cloud in Home Assistant

Medisafe View your medication from Medisafe Cloud in Home Assistant. This integration adds sensors for today's upcoming, taken, skipped, and missed do

Sam Steele 12 Dec 27, 2022
The ABR Control library is a python package for the control and path planning of robotic arms in real or simulated environments.

The ABR Control library is a python package for the control and path planning of robotic arms in real or simulated environments. ABR Control provides API's for the Mujoco, CoppeliaSim (formerly known

Applied Brain Research 277 Jan 05, 2023
A script that publishes power usage data of iDrac enabled servers to an MQTT broker for integration into automation and power monitoring systems

iDracPowerMonitorMQTT This script publishes iDrac power draw data for iDrac 6 enabled servers to an MQTT broker. This can be used to integrate the pow

Lucas Zanchetta 10 Oct 06, 2022
Custom component for Home Assistant that integrates Candy/Haier Wi-Fi washing machines (also known as Simply-Fi).

Candy Home Assistant component Custom component for Home Assistant that integrates Candy/Haier Wi-Fi washing machines (also known as Simply-Fi). This

Olivér Falvai 61 Dec 29, 2022
Universal Xiaomi MIoT integration for Home Assistant

Xiaomi MIoT Raw 简体中文 | English MIoT 协议是小米智能家居从 2018 年起推行的智能设备通信协议规范,此后凡是可接入米家的设备均通过此协议进行通信。此插件按照 MIoT 协议规范与设备通信,实现对设备的状态读取及控制。

1.9k Jan 02, 2023
Alarm Control Panel component for Zigbee Keypads using action_transaction field

hass_transaction_alarm_panel Alarm Control Panel component for Zigbee Keypads using action_transaction field. Works together with zigbee2mqtt Supporte

Konstantin 4 Jun 09, 2022
Provide Unifi device info via api to Home Assistant that will give ap sensors

Unifi AP Device info Provide Unifi device info via api to Home Assistant that will give ap sensors

12 Jan 07, 2023
Huawei Solar sensors for Home Assistant

Huawei Solar Sensors This integration splits out the various values that are fetched from your Huawei Solar inverter into separate HomeAssistant senso

Thijs Walcarius 151 Dec 31, 2022
Raspberry Pi Power Button - Wake/Power Off/Restart(Double Press)

Control Raspberry pi with physically attached button. Wake, Power Off, and Restart (Double Press) . Python3 script runs as a service with easy installation.

Stas Yakobov 16 Oct 22, 2022
A circle of LEDs

This repository contains all the design files, production files and example code for a simple circular LED display.

Pim de Groot 15 Aug 21, 2022
A simple small scale electric car was build which can be driven by remote control and features a fully autonomous parking procedure.

personal-autonomous-parking-car-raspberry A simple electric car model was build using Raspbery pi. The car has remote control and autonomous operation

Kostas Ziovas 2 Jan 26, 2022
Home Assistant custom component to help ev-chargers stay below peak hourly energy levels.

Peaqev ev-charging Peaqev ev-charging is an attempt of charging an ev without breaching a preset monthly max-peak energy level. In order for this inte

Magnus Eldén 35 Dec 24, 2022
OpenStickFirmware is open source software designed to handle any and all tasks required in a custom Fight Stick

OpenStickFirmware is open source software designed to handle any and all tasks required in a custom Fight Stick. It can handle being the brains of your entire stick, or just handling the bells and wh

Sleep Unit 23 Nov 24, 2022
A blender 2.9x addon for managing camera settings

TMG-Camera-Tools A blender 2.9x addon for managing camera settings Tutorial showcasing current features

Mainman002 12 Apr 16, 2022
E-Ink Magic Calendar that automatically syncs to Google Calendar and runs off a battery powered Raspberry Pi Zero

E-Ink Magic Calendar that automatically syncs to Google Calendar and runs off a battery powered Raspberry Pi Zero

2.8k Dec 30, 2022
An open source operating system designed primarily for the Raspberry Pi Pico, written entirely in MicroPython

PycOS An open source operating system designed primarily for the Raspberry Pi Pico, written entirely in MicroPython. "PycOS" is an combination of the

8 Oct 06, 2022
Event-based hardware simulation framework

An event-based multi-device simulation framework providing configuration and orchestration of complex multi-device simulations.

Diamond Light Source Controls Group 3 Feb 01, 2022