A command-line frontend for tuxedo_keyboard, the kernel module for controlling the backlight on Clevo laptops. In simpler terms, it lets you switch the backlight on and off, and set the colors on RGB keyboards. I created this on an Ubuntu-based Linux distro and can't guarantee it will work on other distros.
tuxedo-keyboardDownload it here and follow installation instructions
- Download and unzip, or clone, this repo, then add the script to your path by adding the following line to
~/.bashrc:export PATH=$PATH:<dir>where<dir>is the full path to the repo. For example if you downloaded it to your desktop, it would look likeexport PATH=$PATH:~/Desktop/clevo-keyboard-backlight-control. cdinto the clevo-keyboard-backlight-control directory and make the scripts executable:
chmod +x kbtoggle
chmod +x kbsetcolor
chmod +x batterymon
- In order to run the
batterymonscript through cron, you need to have it in yourrootpath since it has to be added toroots cron table. So, edit/etc/environmentas root and append the path to the script.
This utility needs to unload and reload the keyboard kernel module in order to update its configuration without a reboot. Therefore, it requires root privileges, so when you run it from the command line, it will ask for your password. This gets annoying, but you can easily disable it:
sudo visudo, this will open the/etc/sudoersfile in your terminal- Add the following lines to the end of the file, where
<pathtoscript>is the full path to this utility on your system:
username ALL=(ALL) NOPASSWD: <pathtoscript>/kbtoggle,<pathtoscript>/kbsetcolor,<pathtoscript>/batterymon
- Save and close the file
- To toggle the backlight on and off from the command-line:
kbtoggle - To toggle the backlight on and off with a keyboard shortcut
- Create a custom command shortcut in your system settings (exact steps vary by distro - please google).
- Specify the command as
gksudo <pathtoscript>/kbtoggle. Replacegksudowithkdesudoif using KDE. - Using
gksudoorkdesudowill pop up a graphical interface to ask for your password when you hit your chosen keyboard shortcut. I haven't found a way to make these respect the sudoers file yet, so you'll have to give you password every time.
- To change the colorscheme of the keyboard, from a terminal run
kbsetcolor <colorscheme>where<colorscheme>is the name of one the files inkb-templateswithout the.txtfile extension. Runningkbsetcolorwithout any arguments will give you a list of all the colorscheme arguments you can use. - To create a new colorscheme, run
kbsetcolor -nand follow the prompts. - You can set a default colorscheme to use if there is no colorscheme already set:
kbsetcolor -d <colorscheme> - To make the keyboard change color when the battery is low (20%) or critical (10%), run
sudo crontab -e, add the following line (where<pathtoscript>is the full path to this utility on your system) and save:
*/2 * * * * cd <pathtoscript> && ./batterymon >> batterymon.log
This will check your battery level every 2 minutes, and run a script to change the color of the keyboard if it's low. Any errors from attempting to run the script will be output to batterymon.log.
Note: you can also run batterymon manually from the terminal to check your current battery level on a once-off basis.
The keyboard has 3 sections which can be independantly colored: color_left, color_center, and color_right. You can use any hex values formatted 0x123456 here, but be warned that the actual colors your keyboard is capable of may be limited and you might get unexpected results. The following work reliably on my machine:
Red: 0xFF0000
Green: 0x00FF00
Blue: 0x0000FF
Cyan: 0x00FFFF
Magenta: 0xFF00FF
Yellow: 0xFFFF00
Orange: 0xFF6600
White: 0xFFFFFF
Black (backlight off): 0x000000
Most of the files in kb-templates are named after the initials of the 3 colors in their colorscheme. For example, yrb stands for yellow, red, blue in that order, from left to right, across the keyboard. A few schemes are solid colors (white, cyan) and some are gradients of 2 closely related colors.
You can create your own colorschemes using the kbsetcolor -n command. Alternatively, you can create a colorscheme manually by duplicating one of the existing schemes and replace the specified colors with your choice of colors from the list above. Save it with a name you'll remember so you can easily call it from the command line (you may want to rename your favorite existing schemes for the same reason!)