Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script controll keyboard backlight on IBM ThinkPad X-series
#!/bin/bash
# Vadim Zaliva lord@crocodile.org
# based on https://gist.github.com/hadess/6847281
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
usage() {
echo "This script controll keyboard backlight on IBM ThinkPad X-series"
echo "Usage: ThinkLight [0|1|2]"
echo " 0 - off"
echo " 1 - medium"
echo " 2 - full"
}
if [ "$#" -ne 1 ];then
usage
exit 1
fi
case "$1" in
0)
b="\x03"
;;
1)
b="\x43"
;;
2)
b="\x83"
;;
*)
usage
exit 1
esac
sudo modprobe -r ec_sys
sudo modprobe ec_sys write_support=1
echo -n -e "$b" | sudo dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=13 count=1 conv=notrunc 2> /dev/null
@Redsandro

This comment has been minimized.

Copy link

@Redsandro Redsandro commented May 23, 2016

Also works on Lenovo ThinkPad X1 Carbon. 👍

@thanhlq

This comment has been minimized.

Copy link

@thanhlq thanhlq commented Jul 5, 2016

Thanks so much for your script - it also works on W541!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Jul 13, 2016

Works on T450s 👍

@ryanjdillon

This comment has been minimized.

Copy link

@ryanjdillon ryanjdillon commented Jul 27, 2016

working on x250. thanks!

@nkhine

This comment has been minimized.

Copy link

@nkhine nkhine commented Aug 16, 2016

works on P50S, thanks

@transparentdata243

This comment has been minimized.

Copy link

@transparentdata243 transparentdata243 commented Sep 28, 2016

works on t460p. thank you!

@xopxe

This comment has been minimized.

Copy link

@xopxe xopxe commented Oct 29, 2016

Works on a X1 Yoga.

@lundsted

This comment has been minimized.

Copy link

@lundsted lundsted commented Nov 12, 2016

Works on s540! Thanks!

@ssj-gz

This comment has been minimized.

Copy link

@ssj-gz ssj-gz commented Mar 4, 2017

Works with Kubuntu 14.04 on my T430s - many thanks! :) Can't find anywhere that tells you how to get the Thinklight (the light that sits over the top of the screen, not under the keyboard), though :(

@ericjohnson97

This comment has been minimized.

Copy link

@ericjohnson97 ericjohnson97 commented Jun 18, 2017

Dope!

@johanlerche

This comment has been minimized.

Copy link

@johanlerche johanlerche commented Nov 27, 2017

Works on T470s, thanks

@tetebueno

This comment has been minimized.

Copy link

@tetebueno tetebueno commented Dec 2, 2017

Doesn't seem to work on Lenovo Y520 15IKBN.

@smkamranqadri

This comment has been minimized.

Copy link

@smkamranqadri smkamranqadri commented Dec 19, 2017

Getting this error on t440.

ThinkLight.sh: 6: ThinkLight.sh: [[: not found

@MartinEtcheverry

This comment has been minimized.

Copy link

@MartinEtcheverry MartinEtcheverry commented Feb 6, 2018

excelent ! thank you!

@razvan9921

This comment has been minimized.

Copy link

@razvan9921 razvan9921 commented Apr 28, 2018

Sorry I am new to linux. How do I run this script ?

@SausCode

This comment has been minimized.

Copy link

@SausCode SausCode commented Jul 29, 2018

@razvan9921 copy and paste into .sh, then chmod +x .sh, then sudo ./.sh 0|1|2

@agru

This comment has been minimized.

Copy link

@agru agru commented Nov 2, 2019

Works on P52. Thank you!

@aDorofeev

This comment has been minimized.

Copy link

@aDorofeev aDorofeev commented Jun 26, 2020

Works perfectly with ubuntu 18.04 on t480s! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.