What is this?
A command-line frontend for clevo-xsm-wmi, 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.
- Download it here
- Install dependencies:
sudo apt install gcc make linux-headers-generic
- Open a terminal, enter the clevo-xsm-wmi directory and run
cd module && make && sudo make install
- Just in case:
sudo install -m644 clevo-xsm-wmi.ko /lib/modules/$(uname -r)/extra sudo depmod sudo tee /etc/modules-load.d/clevo-xsm-wmi.conf <<< clevo-xsm-wmi
kdesudofor KDE) if you want to use a keyboard shortcut to run the script. Install with
sudo apt install gksuor
sudo apt install kdesudo. This is probably already installed.
acpifor the battery monitor:
sudo apt install acpi
IMPORTANT: you may need to recompile the clevo-xsm-wmi kernel module after system updates, which sometimes overwrite any changes you've made to the kernel configuration. I don't know of any way around this at the moment.
- Download and unzip, or clone, this repo, then add the script to your path by adding the following line to
<dir>is the full path to the repo. For example if you downloaded it to your desktop, it would look like
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 your
rootpath since it has to be added to
roots cron table. So, edit
/etc/environmentas root and append the path to the script.
Turning off the password check
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:
- 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. Replace
kdesudoif using KDE.
kdesudowill 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
<colorscheme>is the name of one the files in
.txtfile extension. Running
kbsetcolorwithout 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
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. The kernel module supports the following predefined colors:
red yellow green cyan blue magenta white
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!)
- Maintain brightness set by hardware
- Add an option to randomly generate a colorscheme when running
kbsetcolorwith an appropriate parameter.(currently a WIP)
- Any improvements to this hastily hacked-together code are welcomed.