Saturday, December 24, 2016

Colours on my keyboard

A few days ago I had to consider reinstalling Windows on my notebook. Instead I decided to switch to Linux Mint. I've been using Linux Mint in virtual machines for a few years and it worked very well for me. This is the first time I run Linux directly on the host. For development I keep a few Windows virtual machines. I'm very happy with it so far. Everything just worked without much ado, except one detail: The notebook comes with a backlit keyboard with configurable colours. Under Windows I got used to setting it to a dim white colour which works best for me. Since the default colour on boot is dark blue I was looking for a way to change it in Linux. Luckily, I've found a driver for it.

Big kudos to Steven Seeger (klystron) for his efforts!

I can enjoy my comfortable dim white colour again. Or play around; see below. ;-)

Happy holidays and a great year 2017 to everyone!

#!/bin/bash
BLACK=000
BLUE=001
RED=010
MAGENTA=011
GREEN=100
AQUA=101
YELLOW=110
WHITE=111
KBLED=/sys/devices/platform/clevo_wmi/kbled
function setBrightness {
echo $1 > $KBLED/brightness
}
function setColor {
echo $1 > $KBLED/$2
}
function setColors {
setColor $1 left
setColor $1 middle
setColor $1 right
}
function setColors2 {
setColor $1 left
setColor $2 middle
setColor $3 right
setBrightness $4
}
function test1 {
while [ 1 -eq 1 ]; do
setColors $BLUE
sleep 0.5s
setColors $AQUA
sleep 0.5s
setColors $WHITE
sleep 0.5s
done
}
function test2 {
local A=($BLACK $WHITE $BLACK $RED $BLACK $BLUE $BLACK $MAGENTA $BLACK $AQUA $BLACK $YELLOW $BLACK $GREEN)
local L=0
local M=1
local R=2
local B=10
while [ 1 -eq 1 ]; do
while [ 1 -eq 1 ]; do
setColors2 ${A[$L]} ${A[$M]} ${A[$R]} $B
sleep 0.1s
((L++))
if [ $L -eq ${#A[@]} ]; then
L=0
fi
M=$(($L+1))
if [ $M -eq ${#A[@]} ]; then
M=0
fi
R=$((M+1))
if [ $R -eq ${#A[@]} ]; then
R=0
fi
done
done
}
test2
view raw backlit.sh hosted with ❤ by GitHub



No comments: