📅 May 21, 2020
The Logitech G513 RGB Mechanical keyboard has earned its place as the best keyboard I have ever used.
The keys have the best tactile approach, the build quality is superb with the metal top, the wrist rest is durable and soft, the size is convenient, the LEDs are confined to the key letters only (no light bleeding), and it just works with Linux.
But did you know that you can program each LED key individually with Bash to Python to create your own effects?
Do you want two random colors to be spread across the keys upon boot? Would you like a Pac-Man effect that pretends a yellow Pac-Man moves around the keys like a maze? Do you have different lighting patterns that you would like to assign to each user on the same Linux system?
All of this and more is possible with a free Linux program called g810-led that you can use with scripts.
g810-led
You will need to download and compile g810-led yourself since it is not in the Ubuntu repository at the time of this writing. Depending upon your system, you might need to install additional software, such as compilers and USB drivers too.
If you follow the provided instructions and pay attention to any error messages that might arise, you should be able to install this on any Linux system. I have tested this with different Linux Mint systems, and it works flawlessly. Make sure you download the latest version.
“Why use g810-led?”
Logitech does not provide any Linux software to adjust the key lights the way the Windows version does. So, we need to use a substitute. However this is not a drawback because we can use g810-led in scripts that can yield more creative results than the official software allows.
“Why is this called g810-led? Will it work with a G513 keyboard?”
Yes. Despite the name, g810-led controls the LEDs for a number of compatible Logitech RGB keyboards including the G513. If you have a G910 or a G610, for example, this article should still apply as long as you can run g810-led.
Please consult the g810-led page for a list of compatible keyboards.
What is My Keyboard’s Product ID?
You need to know your keyboard’s Product ID. This is how g810-led identifies the keyboard.
After installation, look for your keyboard’s Product ID by running this in a terminal:
g810-led --list-keyboards
Device: Logitech - G513 Carbon Linear Vendor ID: 046d Product ID: c33c
For the Logitech G513, the Product ID is c33c. If you have a different keyboard, then your product ID might be different. Remember this value for your scripts in case you encounter issues that require it. The correct Vendor ID and Product ID must be used with a compatible keyboard. If not, then g810-led might not work and will show the message:
Matching or compatible device not found !
You can also find the Vendor ID and Product ID in Vendor:Product format using lsusb.
lsusb
Look for your keyboard in the listing:
Bus 005 Device 007: ID 046d:c33c Logitech, Inc.
046d is the Vendor ID, and c33c is the Product ID.
The Basics
Run g810-led by itself to see a list of options. This article is using g810-led version 0.4.2, and it works without specifying a Product ID in Linux Mint 19.2. For example, to set all keys to the same colors, enter this:
g810-led -a 12ff12
The -a option must be followed by a color value as a six-digit hex value without a hash character. (Use FF0000, not #FF0000.) However, this command produces the following message:
Matching or compatible device not found !
Even though the keyboard is connected and functioning properly (in fact, it was used to type this command), we need to specify the Vendor ID and the Product ID of the keyboard in use. Since we are using the G513 in this example, we need to use the -dv and -dp options to set the Vendor ID and the Product ID to 046d and c33c. We also need to used the -tuk 1 option (test unsupported keyboard).
g810-led -dv 046d -dp c33c -tuk 1 -a 12ff12
A Problem: Missing Sticky Bit
For some reason, I was still receiving the error message despite using known good commands. No idea why. I reinstalled g810-led, but the device not found error persisted. To make matters more confusing, startup scripts that set the keyboard colors worked fine — using the same commands. A puzzler. Unplugging the keyboard or rebooting the system did not fix this issue.
However running the command using sudo did work.
sudo g810-led -dv 046d -dp c33c -tuk 1 -a 909090
The solution is the set the SUID of the g810-led binary. whereis revealed that g810-led is located in the path
/usr/bin/g810-led
In a terminal, run this command to set the sticky bit for the user so sudo is not required.
sudo chmod u+s /usr/bin/g810-led
Now, g810-led will work without sudo, and the error disappears.
g810-led -dv 046d -dp c33c -tuk 1 -a 00ff00
In fact, we find that we no longer need the Vendor ID or the Product ID, so we can use g810-led alone.
Change All Key Colors
Use the -a option. The hex value that follows sets one color for all keys. Case does not matter for the hex color, so ff00ab and FF00AB are the same.
Red
g810-led -a ff0000
Green
g810-led -a 00ff00
Blue
g810-led -a 0000ff
Any combination of RGB hex values will adjust the colors. If you need help choosing a color and its hex value, use the color wheel in GIMP or use the Gpick color picker found in the repository. Just make sure that the hex value does not contain a hash character. Use the six hex digits by themselves.
Change a Specific Key
We are not limited to all keys. We can set an individual key to any color we like using the -k option followed by the name of the key to set. With the keyboard already set to all keys blue, let’s change the ‘G’ key to a pale color: F3E2BB.
g810-led -k G F3E2BB
Change the Enter key to light green
g810-led -k Enter B1E4A0
We now have blue, pale, and light green together.
Change Groups of Keys
Sure, we could list every key on the keyboard and color it one by one. There is a place for doing this in scripts as we will see later, but this is too tedious for now.
Some key groups are used together more frequently than others, so they are named and treated as a group. Rather than color each key in a group the same color individually, we can use one statement to color them all using the group’s name.
Group names are preset in g810-led. To list them, run
g810-led --help-keys
Suppose we want to color all numeric keys orange (E3591C). We use the -g option with the numeric group name and color.
g810-led -g numeric E3591C
Now, all of the ten-key numeric keys receive the same pumpkin orange color. How convenient!
Let’s change all modifier keys to lavender (949AF0).
g810-led -g modifiers 949AF0
Now, the Shift, Alt, and Ctrl keys have a pale purple color on the keyboard.
Note that the actual LED color on the keyboard will not always match the color seen on the monitor exactly due to differences between the monitor and the keyboard LEDs. This is normal. Monitors and keyboard LEDs are two different things.
Let’s give all function keys a pinkish color (F094BD).
g810-led -g fkeys F094BD
The group name for keys F1 to F12 is fkeys.
You can use groups as much as you like. The principle is the same.
Profiles
As you can guess, all of these commands can add up — especially if you want to fine-tune each key on your keyboard. This can add up to a lot of commands being typed on the command line.
We could use a script, but scripts are best used when we need to implement calculations and logic. For a series of one or more key color changes, g810-led supports profiles. A profile is a file that g810-led reads in order to set the key colors.
To create a profile, create an empty text file in your home directory or anywhere else that you choose. Its location does not matter as long as you can access it from a command line. Name it whatever you want. In this example, we will name the file profile.
Each line in a profile is one g810-led color command. It is pretty much an option without the dash.
On the command line, we would enter
g810-led -a D3E4A0
to set all keys to a pale olive color, but in a profile we enter
a D3E4A0
on a line of its own.
On a new line, we will use a command that sets all functions keys to the same slate gray color. Enter c (for commit) as the last line. Our profile should look like this:
a D3E4A0 g fkeys 516572 c
Save the profile. To use this profile, use the -p option followed by the name of the profile file.
g810-led -p profile
The keys will now change to olive green for everything and slate gray for the function keys.
Profile commands are read from top to bottom and applied in order. Newer commands will overwrite earlier commands, so if we set the G key to red and then another command sets it to blue, G will be blue when the profile completes.
a D3E4A0 g fkeys 516572 k g ff0000 k g 0000ff c
Notice that G is first set to red, and then it is set to blue on the second after. G will remain blue because that was the last color applied.
Example Profiles
Several example profiles are provided in the g810-led-master/sample_profiles directory found in the source download. Please have a look at these to see how they work.
Effects
We are not limited to static colors. We can animate the keyboard with color too! These effects can even be applied in profiles.
Effects use the -fx option followed by the name of the effect. To find the effect names, enter
g810-led --help-effects
Effects tend to depend upon the type of keyboard, so there are no guarantees that all effects will work with all keyboards. They seem to be fully functional with the G513.
CWAVE Effect
g810-led -fx cwave all 20
This makes the keys change rainbow colors in a wave from right to left.
Cycle Colors
g810-led -fx cycle all 20
This cycles all keys through all colors together. If you have ever seen LED bulbs that change into different colors smoothly, then you have an idea of what this does.
Effects are animated, so it is best to see these in action. Pictures cannot help much either. Rather than reading a description, experiment!
Bash Scripting
Okay. We can change colors for all keys, a single key, or a group of keys, but what if we want to add some logic, such as dynamically generate a random color? We need to use scripting for this.
Here is an example Bash script that will randomly generate two colors and randomly assign them to various keys. Each time the script runs, the key colors are different, and this helps alleviate boredom and repetition.
#!/bin/bash function getColor() { rgb=$(printf "%02x%02x%02x" $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256))) echo $rgb } # Define colors COLOR1=$(getColor) COLOR2=$(getColor) # Save to colors log echo "$(date): $COLOR1 $COLOR2" >> ~/etc/keycolors.txt arrKeys=('esc' # Function F1-F12 'f1' 'f2' 'f3' 'f4' 'f5' 'f6' 'f7' 'f8' 'f9' 'f10' 'f11' 'f12' # Print Screen Scroll Lock Pause 'printscr' 'scrolllock' 'pause' 'ins' 'del' 'home' 'end' 'pageup' 'pagedown' # Arrow keys 'top' 'right' 'bottom' 'left' # Numpad 'numlock' 'numslash' 'numasterisk' 'numminus' 'numplus' 'numenter' 'num0' 'num1' 'num2' 'num3' 'num4' 'num5' 'num6' 'num7' 'num8' 'num9' 'num.' 'tilde' '1' '2' '3' '4' '5' '6' '7' '8' '9' '0' 'minus' 'equal' 'backspace' 'tab' 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'u' 'w' 'x' 'y' 'z' 'comma' 'period' 'slash' 'semicolon' 'quote' 'open_bracket' 'close_bracket' 'backslash' 'enter' 'shiftright' 'shiftleft' 'caps' 'winright' 'winleft' 'menu' 'space' 'capslock' 'ctrlleft' 'ctrlright' 'altleft' 'altright' 'gamemode' 'capsindicator') # Set all keys to off in case of "stuck" key colors g810-led -dv 046d -dp c33c -tuk 1 -a 000000 # Light each key in array with each other COLOR1 or COLOR2 for key in ${arrKeys[*]} do if [ $((RANDOM % 2)) == 1 ] then g810-led -dv 046d -dp c33c -tuk 1 -k $key "$COLOR1" else g810-led -dv 046d -dp c33c -tuk 1 -k $key "$COLOR2" fi done
A g810-led profile cannot do this alone. However, the script can call the g810-led program to set the keys in the for loop at the end.
Each key has a name, so we create an array of all of the keys we want to assign a color to. The for loop goes through each element in order but randomly picks 0 or 1. Random colors are generated in the RRGGBB format needed by g810-led by calling the getColor() function. The results are stored in two variables: $COLOR1 and $COLOR2. Depending upon whether 0 or 1 is picked for the current key, one of the two colors will be assigned to that key. This can produce some unpredictable yet attractive color coordinations.
The echo to a file saves the date and generated color values just in case we find a color combination that we really like and want to know what hex values created it for future use.
The line that clears all keys to black in case of “stuck” colors is probably not necessary anymore with the latest version of g810-led, but I left it just in case. In earlier versions of g810-led, I experienced a quirky issue when a random key would not change color. Adding this line blanks all keys to start fresh. It corrected the problem. Again, probably not necessary, but it is added as a precaution. An out-of-place key color stands out.
Key Groups with Scripts
Here is another Bash example utilizing key groups. This generates five random colors and assigns them to five different groups of keys.
#!/bin/bash # Generate random hex RGB value. No # character. function getColor() { #return hexdump -n 3 -v -e '3/1 "%02X" "\n"' /dev/urandom rgb=$(printf "%02x%02x%02x" $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256))) echo $rgb } # Random Colors colorKeys=$(getColor) colorFKeys=$(getColor) colorNumeric=$(getColor) colorFunctions=$(getColor) colorModifiers=$(getColor) # Keys g810-led -dv 046d -dp c33c -tuk 1 -g fkeys $colorFKeys g810-led -dv 046d -dp c33c -tuk 1 -g functions $colorFunctions g810-led -dv 046d -dp c33c -tuk 1 -g numeric $colorNumeric g810-led -dv 046d -dp c33c -tuk 1 -g arrows $colorFKeys g810-led -dv 046d -dp c33c -tuk 1 -g keys $colorKeys g810-led -dv 046d -dp c33c -tuk 1 -g modifiers $colorModifiers
The Vendor ID and Product ID are not necessary and can be omitted with newer versions of g810-led.
Python Scripting
Pac-Man Maze
We can use Python to set key colors by using subprocess.call(). Here is an interesting Python 3 script that creates an animated Pac-Man effect.
#!/usr/bin/env python3 import subprocess, time MAZE_COLOR = '6964DD' GHOST_COLOR = 'ff0000' PACMAN_COLOR = 'DDBA64' POWER_PELLET_COLOR = 'ffffff' DOT_COLOR = 'EDEDBF' # Set maze border colors subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -a ' + MAZE_COLOR, shell=True) # Set dot pattern dots = [ 'tilde', '1', '2', '3', '4', '5', 'f4', 'f5', '7', 'u', 'i', 'k', 'l', 'semicolon', 'p', '0', '9', 'f7', 'f8', 'f9', 'minus', 'equal', 'backspace', 'backslash', 'del', 'insert', 'home', 'pageup', 'pagedown', 'num7', 'numlock', 'numslash', 'numasterisk', 'numminus', 'numplus', 'num3', 'num2', 'num1', 'num0', 'right', 'top', 'left', 'ctrlright', 'ctrlright', 'shiftright', 'slash', 'period', 'altright', 'space', 'n', 'b', 'g', 'f', 'd', 'c', 'x', 's', 'a', 'caps', 'shiftleft', 'ctrlleft', ] for dot in dots: subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -k ' + dot + ' ' + DOT_COLOR, shell=True) path = dots # Set power pellet subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -k ctrlleft ' + POWER_PELLET_COLOR, shell=True) for place in path: subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -k ' + place + ' ' + PACMAN_COLOR, shell=True) time.sleep(0.10) # Dot gobbled subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -k ' + place + ' 000000', shell=True) # Set final subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -a ' + MAZE_COLOR, shell=True) keyset = [ 'w', 'a', 's', 'd', 'enter', 'f9', 'scrolllock', 'pause' ] # Modifier keys subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -g modifiers DDBA64', shell=True) # function key subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -k winright ' + MAZE_COLOR, shell=True) for key in keyset: subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -k ' + key + ' DDBA64', shell=True)
This creates a blue rudimentary maze (some imagination required) out of the keyboard keys and assigns light-yellow pellets within the “maze.” Then, a bright yellow color “gobbles” all of the dots in the maze by clearing them out. Once all dots have been gobbled, the keys are set to a predefined blue/yellow scheme, and the script ends.
Since this is animated, the script takes a few seconds to animate. If it is started from a terminal, then the terminal must remain open until it completes. The purpose of this animation is to have a startup color animation when the computer boots or the user logs in. It looks cool!
Starlight
This Python script demonstrates an infinite loop. All keys are initially set to dark blue to emulate the night sky, and then random keys fade in and out as a bright yellow color to emulate the twinkling of stars. Keys are chosen at random for variety.
The main point behind this one is that each “star twinkle” fades in and out slowly. This creates the effect of several stars fading in and out asynchronously. The effect is achieved using Python threading so each key is controlled by its own thread. Yes, it can consume CPU time. If executed from a terminal, the terminal will show which keys are being animated.
#!//usr/bin/env python3 import threading import subprocess import random import time BACKGROUND = '1c1c61' # Dark blue STARLIGHT = 'ffe400' # Yellow # Set keyboard background color to simulate night sky subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -a ' + BACKGROUND, shell=True) # Each key is illuminated separately as its own thread. class newThread (threading.Thread): def __init__(self, threadID, keyName, counter): threading.Thread.__init__(self) self.threadID = threadID self.keyName = keyName self.counter = counter def run(self): print('Starting: ' + self.keyName) fadeColor(self.keyName, self.counter, 1, STARLIGHT, True) fadeColor(self.keyName, self.counter, 1, STARLIGHT, False) print('Exiting: ' + self.keyName) # Convert hex string into separate RGB values def hexToRGB(color): return list(int(color[i:i+2], 16) for i in (0, 2, 4)) # ----------------------------------------------------------------------- # Fade key color in to STARLIGHT value. # ----------------------------------------------------------------------- # fadeDir is fade direction. # True = fade in from BACKGROUND color to STARLIGHT color # False = fade out from starlight color to BACKGROUND color # ----------------------------------------------------------------------- def fadeColor(keyName, delay, step, color, fadeDir): step = 1 # Convert hex STARLIGHT color to RGB keyRGB = hexToRGB(color) # Convert hex BACKGROUND color to RGB backRGB = hexToRGB(BACKGROUND) # Fade in if fadeDir: # Start at BACKGROUND newRed = backRGB[0] newGreen = backRGB[1] newBlue = backRGB[2] # Stop at STARLIGHT stopRed = keyRGB[0] stopGreen = keyRGB[1] stopBlue = keyRGB[2] # Fade out else: # Start at STARLIGHT newRed = keyRGB[0] newGreen = keyRGB[1] newBlue = keyRGB[2] # Stop at Background stopRed = backRGB[0] stopGreen = backRGB[1] stopBlue = backRGB[2] newColor = False stopColor = False if fadeDir: stopColor = STARLIGHT else: stopColor = BACKGROUND while not newColor == stopColor: # Form new hex color newColor = '{0:02x}{1:02x}{2:02x}'.format(newRed, newGreen, newBlue) subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -k ' + keyName + ' ' + newColor, shell=True) # adjust color values. Increment color if less than, decrement if greater than if newRed < stopRed: newRed += step elif newRed > stopRed: newRed -= step if newGreen < stopGreen: newGreen += step elif newGreen > stopGreen: newGreen -= step if newBlue < stopBlue: newBlue += step elif newBlue > stopBlue: newBlue -= step # ------------------------------------------------------------ # List of keys to affect # ------------------------------------------------------------ keys = [ 'esc', # Function F1-F12 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', # Print Screen, Scroll Lock, Pause 'printscr', 'scrolllock', 'pause', 'ins', 'del', 'home', 'end', 'pageup', 'pagedown', # Arrow keys 'top', 'right', 'bottom', 'left', # Numpad 'numlock', 'numslash', 'numasterisk', 'numminus', 'numplus', 'numenter', 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6', 'num7', 'num8', 'num9', 'num.', 'tilde', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'minus', 'equal', 'backspace', 'tab', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 's', 't', 'u', 'v', 'u', 'w', 'x', 'y', 'z', 'comma', 'period', 'slash', 'semicolon', 'quote', 'open_bracket', 'close_bracket', 'backslash', 'enter', 'shiftright', 'shiftleft', 'caps', 'winright', 'winleft', 'menu', 'space', 'capslock', 'ctrlleft', 'ctrlright', 'altleft', 'altright', 'gamemode', 'capsindicator' ] # Store active keys. threadList = {} try: while True: # Prevent too many threads in dictionary if len(threadList) > 5: for key in threadList: threadList[key].join() threadList = {} # Reset for key in random.sample(keys, 5): if not key in threadList: threadList[key] = newThread(key, key, 1) # Use keyname as dictionary key threadList[key].handled = True threadList[key].start() time.sleep(random.random() * 1.5) else: # Must wait for thread to finish and remove threadList[key].join() threadList.pop(key, None) except KeyboardInterrupt: # Handle CTRL+C for key in threadList: threadList[key].join() subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -a ' + BACKGROUND, shell=True)
As long as the terminal is running the script, it will execute as an infinite loop. CTRL+C stops the script.
Each Key Random
Another fun piece of keyboard eyecandy is this little gem that assigns a random color to every key on the keyboard every second. It is a fun effect to watch, and it makes the keyboard feel alive…as if the computer is “thinking.”
#!/usr/bin/env python3 import time import random import subprocess # ------------------------------------------------------------ # Generate random hex RGB value. # Retry if less than #111111 # ------------------------------------------------------------ def getColor(): color = '{:06x}'.format(random.randint(0, 0xffffff)) if color < '222222': color = 'ffffff' return color # ------------------------------------------------------------ # List of keys to affect # ------------------------------------------------------------ keys = [ 'esc', # Function F1-F12 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', # Print Screen, Scroll Lock, Pause 'printscr', 'scrolllock', 'pause', 'ins', 'del', 'home', 'end', 'pageup', 'pagedown', # Arrow keys 'top', 'right', 'bottom', 'left', # Numpad 'numlock', 'numslash', 'numasterisk', 'numminus', 'numplus', 'numenter', 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6', 'num7', 'num8', 'num9', 'num.', 'tilde', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'minus', 'equal', 'backspace', 'tab', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 's', 't', 'u', 'v', 'u', 'w', 'x', 'y', 'z', 'comma', 'period', 'slash', 'semicolon', 'quote', 'open_bracket', 'close_bracket', 'backslash', 'enter', 'shiftright', 'shiftleft', 'caps', 'winright', 'winleft', 'menu', 'space', 'capslock', 'ctrlleft', 'ctrlright', 'altleft', 'altright', 'gamemode', 'capsindicator' ] while True: random.shuffle(keys) for key in keys: subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -k ' + key + ' ' + getColor(), shell=True) # time.sleep(0.25) # Adds delay between each key color change time.sleep(1) #subprocess.call('g810-led -dv 046d -dp c33c -tuk 1 -a 000000', shell=True)
This, too, will execute as an infinite loop. CPU usage is not as high as the Starlight script.
Starting Scripts at User Login
If you create a script or design that you like and want it to automatically run upon logging in, just add it as a startup application in Linux Mint’s System Settings. (Other Linux distributions offer similar mechanisms.)
Make sure that the script is set to executable.
Default Profile
If you have booted your computer with g810-led installed or unplug and reconnect the keyboard, you will probably notice that it resets to a preset profile losing whatever color scheme might be active at the time. This profile is located in /etc/g810-led/profile, and it is a profile file like any other. You can change anything you like in this profile, and it will become the new default that sets the keyboard when the system boots. It can still be overwritten anytime g810-led sets keys or when running a script.
If you have a color scheme that you like, you can set it here to be the default. Make sure to end the profile with c to commit the changes.
Example default profile:
k m 24b8d3 k shiftleft e18998 k e 24b8d3 k j e18998 k b 24b8d3 k 0 e18998 k 4 24b8d3 k left e18998 k capsindicator 24b8d3 k winright e18998 k num1 24b8d3 k equal e18998 k f4 24b8d3 c
Run a Script as Default
What if you want logic or random colors on your keyboard during boot or keyboard reconnection? This requires a script. With g810-led installed, have a look at the /etc/udev/rules.d directory and locate the g810-led.rules file.
Open g810-led.rules and take a look at it. There will be many lines that look something like this:
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c336", MODE="666" RUN+="/usr/bin/g213-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c330", MODE="666" RUN+="/usr/bin/g410-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c33a", MODE="666" RUN+="/usr/bin/g413-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c342", MODE="666" RUN+="/usr/bin/g512-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c33c", MODE="666" RUN+="/usr/bin/g513-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c333", MODE="666" RUN+="/usr/bin/g610-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c338", MODE="666" RUN+="/usr/bin/g610-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c331", MODE="666" RUN+="/usr/bin/g810-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c337", MODE="666" RUN+="/usr/bin/g810-led -p /etc/g810-led/profile"
…More lines follow
This is how g810-led runs whenever the computer boots or whenever the keyboard is disconnected and then reconnected. It runs the command
/usr/bin/g810-led -p /etc/g810-led/profile
g810-led loads the same script for every line. The only difference is the Product ID per line to make sure that something will work. We can change the path in RUN+=”/usr/bin/g810-led -p /etc/g810-led/profile” to whatever script we like to set the colors. Suppose we have a script located in /etc/g810-led named mycolors.sh that sets the G513 to a special color scheme with random colors. G513’s Product ID is c33c, so all we have to do is set a new path for that line and comment out the others since they are unnecessary for a G513 keyboard. Like this:
#ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c330", MODE="666" RUN+="/usr/bin/g410-led -p /etc/g810-led/profile" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c33a", MODE="666" RUN+="/usr/bin/g413-led -p /etc/g810-led/profile" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c342", MODE="666" RUN+="/usr/bin/g512-led -p /etc/g810-led/profile" ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c33c", MODE="666" RUN+="/etc/g810-led/mycolors.sh" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c333", MODE="666" RUN+="/usr/bin/g610-led -p /etc/g810-led/profile" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c338", MODE="666" RUN+="/usr/bin/g610-led -p /etc/g810-led/profile" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c331", MODE="666" RUN+="/usr/bin/g810-led -p /etc/g810-led/profile" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c337", MODE="666" RUN+="/usr/bin/g810-led -p /etc/g810-led/profile" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c32b", MODE="666" RUN+="/usr/bin/g910-led -p /etc/g810-led/profile" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c335", MODE="666" RUN+="/usr/bin/g910-led -p /etc/g810-led/profile" #ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c339", MODE="666" RUN+="/usr/bin/gpro-led -p /etc/g810-led/profile"
Now, this script will run whenever the computer boots and initialize the keyboard to whatever effect the script produces. Note that a user’s startup script will replace the keyboard colors if a startup script exists. Personally, I recommend picking one or the other. Do not use both together. If changing the boot default in g810-led.rules, then disable the start up script in Startup Applications. There were a few times that I had issues of not all keys clearing with older versions of g810-led. Rare, but it happened.
Conclusion
At this point, explore and experiment! You imagination is the limit! There are numerous possibilities with g810-led and scripting to create eye-popping color effects, so have fun!