A script to change the key colors on a Logitech G213 Prodigy Gaming Keyboard.
Please also check out these awesome forks:
G213Colors GUI - A cool grafical GUI you can use from the main menu
G213Colors GUI + installation script - The GUI plus an easy installation script
What it does
G213Colors lets you set the color(s) and certain effects of the illuminated keys on a G213 keyboard under Linux.
The original Software and Hardware has the following downsides:
- There is no Linux software
- The keyboard does not save the last setting, one has to re-set it every bootup / disconnect
- The keyboard starts up with an annoying color cycle animation
- The original software is unusable with KVM switches
So i decided to reverse engineer their USB protocol and to write my own script to control the keyboard.
G213Colors was built and tested under Linux for the G213 keyboard specifically, but after some adaptation it could potentially be run under other OS'es and used for other Logitech keyboards as well. Please understand that i do not support any such adaptation, if you want to do it you are on your own.
The "Wave" color effect that is available with the Logitech software could not be replicated since it is completely generated in the software by updating the colors every x ms (In contrast to the other effects which run on the keyboard itself). You could generate this effect with a script, but since G213Colors has to detach the kernel driver from one of the G213's interfaces to send data out the multimedia keys would most likely stop working. Unfortunately this is a side effect of the linux driver structure.
Either download the G213Colors.py file to a directory of your choosing or clone this project with git.
- Python >= 2.4 or 3.x (which is usually already installed)
- PyUSB (please see their instructions on how to install)
- RandomColor (pip install randomcolor)
Please ignore the pcap directory, i added the pcap files i used for reverse engineering just in case someone wants to work with them. They can be opened with Wireshark.
For help on how to use G213Colors call the script without any arguments:
sudo python G213Colors.py
G213Colors needs to be run as root as long as your user doesn't have access privileges for that USB device (How to do this, please use "046d" as idVendor and "c336" as idProduct).
- Added feature: Assign random colors to keyboard by using -ra or -rs flag
- Fixed bug preventing setting all 5 color fields correctly, thanks to @oncecreated for finding this solution!
- Added propper validation of user inputs
- Complete refactoring
- Initial checkin