Change keyboard backlight from cmd line?

Hi, is it possible to change keyb backlight colour from the command line (similar to hyper + trackball)? Any pointers?
thx

Yes, you can send commands to /dev/hidraw0 to control the RGB backlight.

Looks like by default you have to be root to write to /dev/hidraw0 and then this works:

echo -n -e ‘xLRGB\x00\xFF\x00’ > /dev/hidraw0

Where 00 FF 00 is an RGB code (although it appears the order is Blue,Green,Red ?)

(check the end of main.c in the keyboard firmware source for various 4 letter commands you can send to hidraw0)

10 Likes

thx
tried it with sudo, but get permission denied, … hmm

Sudo won’t work because it doesn’t apply to the > output redirection which gets executed in the context of your shell. You can try su -c "..." instead of sudo.

2 Likes
printf 'xLRGB\x00\xFF\x00' | sudo tee /dev/hidraw0

In POSIX sh, echo flags are undefined, so maybe instead of echo, you want to use printf in case you are writing a script that can be used by more people than just you.

7 Likes

Sending this command to /dev/hidraw does not work on my Pocket.

EDIT: solved on my pocket, needed a hard reset (physical power switch).

2 Likes

Is there a way to keep the keyboard backlight color after a restart? Using the printf command I can get the color to change, but it goes back to magenta when I restart the device.

There may be a more elegant method, but I’d just bung the line in a bash script and have it run on boot.

Neat; where would “bash” go in the “printf ‘xLRGB\x##\x##\x##’ | sudo tee /dev/hidraw0” command?