13

Here's my situation:

I recently purchased a Sager NP9170 (same as the Clevo P170EM) and it has a multi-colored, backlit keyboard. Under Windows 7, you can launch an app that allows you to change the color of the backlighting to any of a handful of colors (blue, green, red, etc).

I want that same functionality under Linux. I haven't been able to find any software that does this, so I guess I'm going to have to write it myself. I'm a programmer by trade, but I've haven't done much low level programming, and I've certainly never written a device driver, so I was wondering if anyone could answer these two questions:

1) Is there any software already out there that does this sort of thing? I've looked fairly thoroughly but haven't found anything applicable.

2) Where would I start in trying to reverse engineer this sort of thing? Any useful articles, tutorials, books that might help?

And just to clarify: The backlighting already works, that's not the problem. I just want to be able to change the color of the backlighting. This functionality is supported by the hardware. The laptop came with windows software that does this and I want the same functionality in Linux. I am willing to write this software myself, I just want to know the best way to go about it.

Thanks!

0

4 Answers 4

9

Well, as it turns out, someone else actually figured it out. A huge "Thank You" to "klystron34" over in the notebookreview.com forums. Check out the forum thread for more information.

Note: As far as I know, this will work for many/most laptops based on the stock Clevo P150EM and the P170EM. This was personally verified by me on a Sager NP9170 on Ubuntu 12.04. Proceed at your own risk. I'm not responsible for any damage you might cause doing this, and any other standard internet disclaimers. Proceed at your own risk. Now, onto the good stuff:

First, you need to be able to compile a kernel module, so update your repositories:

sudo apt-get update

Now, install git, the build tools and the kernel source:

sudo apt-get install git build-essential linux-source

Now create a working directory. I prefer to use a "dev" folder located in my home directory:

cd ˜
mkdir dev
cd dev

Now, download the source for the kernel module:

git clone git://git.code.sf.net/p/clevo-wmi/code clevo-wmi-code

Go into the directory with the source code:

cd clevo-wmi-code

"Make" the kernel module:

make

You should now have a file called clevo_wmi.ko

Now, let's test and see if the module actually works by loading the module:

sudo insmod /home/<your-username-here>/dev/clevo-wmi-code/clevo_wmi.ko

If it worked, you should now have a new directory called:

/sys/devices/platform/clevo_wmi/kbled

Change over to that directory:

cd /sys/devices/platform/clevo_wmi/kbled

You should now be able to change the colour of the middle section of your keyboard by executing the following command:

sudo su -c 'echo 100 > middle'

The middle section of your keyboard should now be green. Replace middle with left or right to change the corresponding section of the keyboard. Here's a list of the color codes:

GRB (Green-Red-Blue)
000 - Off
111 - White
100 - Green
010 - Red
001 - Blue
110 - Yellow
011 - Purple
101 - Aqua

To install this kernel module permanently, copy it into the same location as the rest of your kernel modules (NOTE: You will probably have to perform this step and the next step anytime you change your kernel):

sudo cp ~/dev/clevo-wmi-code/clevo_wmi.ko /lib/modules/`uname -r`/kernel/drivers/platform/x86/

Next, do this (I think rebuilds the list of kernel modules):

sudo depmod -a

Then edit your /etc/modules file and add this line to the end of the file:

clevo_wmi

Save your changes to /etc/modules.

Now, whenever you reboot, the module should be loaded and you can then change the colour of the backlight on your keyboard. Figuring out how to have it change colours on reboot and remembering your last colour setting is an exercise left up to the reader. Check the docs directory in the sourcecode for instructions on how to use the dynamic colour changing features.

Thanks agin to the developer(s) that worked hard on writing this kernel module!

2
  • I am delighted :D Thanks. Would be great if it got included in the kernel someday. BTW: are there any standard ways of exposing this to the UI, so that Unity or other WM could use it?
    – bcelary
    Apr 18, 2014 at 15:33
  • 1
    As of 2017-Dec there are some Clevo models that the driver does not yet support. The random_fade and random_flicker work, but setting certain sections of the keyboard to specific colors does not work.
    – Mutant Bob
    Dec 7, 2017 at 16:06
0

How do you access such functionality?

This can probably be achieved by some clever scripting, and startup functionality.

( In Windows you would likely need to write code in an exotic memory model allowing direct hardware access, or instead need to write a driver (and API) to detect and control the hardware. )


How do you select your preferences?

Then some basic scripts (or icon calling scripts) could select a specific color-preference.

If you used Python, for a front-end GUI, it would also be fairly simple.

5
0

There already exists an driver for all the functions for the whole keyboard AND flymode-key! TUXEDO Computers developed this driver and offers it through their support-forum: http://www.linux-onlineshop.de/forum/index.php?page=Thread&threadID=26

Have fun :)

0

I created a script for changing the colors using the above method by Pope. You can find it here: pb aDWe9s6d (not sure if the formatting here will work right so safer to copy from there)

#! /bin/bash
#changes keyboard colors
#Noah B.

#Prompt for root
[ "$UID" -eq 0 ] || exec sudo bash "$0" "$@"

off=000
white=111
green=100
red=010
blue=001
yellow=110
purple=011
aqua=101

left=$1
l_code=000
middle=$2
m_code=000
right=$3
r_code=000

#LEFT SIDE

if [ -z "$left" ]
then 
    echo "Enter desired color for the left side:
    (off/white/green/red/blue/yellow/purple/aqua)"
read -p "Color choice: " left
fi

eval "l_code=\$$left"

echo $l_code > /sys/devices/platform/clevo_wmi/kbled/left

#MIDDLE

if [ -z "$middle" ]
then
    echo "Enter desired color for the middle:
    (off/white/green/red/blue/yellow/purple/aqua)"
read -p "Color choice: " middle
fi

eval "m_code=\$$middle"

echo $m_code > /sys/devices/platform/clevo_wmi/kbled/middle

#RIGHT SIDE

if [ -z "$right" ]
then
    echo "Enter desired color for the right side:
    (off/white/green/red/blue/yellow/purple/aqua)"
read -p "Color choice: " right
fi

eval "r_code=\$$right"

echo $r_code > /sys/devices/platform/clevo_wmi/kbled/right

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .