Skip to content

Instantly share code, notes, and snippets.

@vzaliva
Created May 22, 2016 14:27
Show Gist options
  • Select an option

  • Save vzaliva/0adba7bc40e2f31a0b5f802af2a63267 to your computer and use it in GitHub Desktop.

Select an option

Save vzaliva/0adba7bc40e2f31a0b5f802af2a63267 to your computer and use it in GitHub Desktop.
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

Copy link
Copy Markdown

Also works on Lenovo ThinkPad X1 Carbon. 👍

@thanhlq

thanhlq commented Jul 5, 2016

Copy link
Copy Markdown

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

ghost commented Jul 13, 2016

Copy link
Copy Markdown

Works on T450s 👍

@ryanjdillon

Copy link
Copy Markdown

working on x250. thanks!

@nkhine

nkhine commented Aug 16, 2016

Copy link
Copy Markdown

works on P50S, thanks

@transparentdata243

Copy link
Copy Markdown

works on t460p. thank you!

@xopxe

xopxe commented Oct 29, 2016

Copy link
Copy Markdown

Works on a X1 Yoga.

@Delta-40

Copy link
Copy Markdown

Works on s540! Thanks!

@ssj-gz

ssj-gz commented Mar 4, 2017

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Dope!

@johanlerche

Copy link
Copy Markdown

Works on T470s, thanks

@smkamranqadri

Copy link
Copy Markdown

Getting this error on t440.

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

@MartinEtcheverry

Copy link
Copy Markdown

excelent ! thank you!

@razvan9921

Copy link
Copy Markdown

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

@SausCode

Copy link
Copy Markdown

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

@agru

agru commented Nov 2, 2019

Copy link
Copy Markdown

Works on P52. Thank you!

@aDorofeev

Copy link
Copy Markdown

Works perfectly with ubuntu 18.04 on t480s! Thank you!

@marschr

marschr commented Apr 5, 2021

Copy link
Copy Markdown

Thanks for the many insights!
Kinda works on my Ideapad Flex 5i (14iil05)
address is 0xc2 (194 dec) and values are 0x00, 0x01 and 0x02 for off, low, hi, respectively.
echo -n -e 1 | sudo dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=194 count=1 conv=notrunc
also, address 0xcc (204 dec) seems to report the current state of the kb backlit (0x50 = off; 0x70 = on) but writing to it does nothing =|
is there an address for the backlight timeout?

@osamalzabidi

Copy link
Copy Markdown

Doesn't seem to work on Lenovo E480

@vzaliva

vzaliva commented Oct 21, 2021

Copy link
Copy Markdown
Author

@omamkaz Sorry I do not have this model to test and help. For what it's worth it does not work on my Carbon X1 either.
But you can use Fn+SPACE keyboard sequence.

@osamalzabidi

Copy link
Copy Markdown

Fn+SPACE also Not work!, Thanks for your response

@osamalzabidi

Copy link
Copy Markdown

@vzaliva are you know where I can find some solution for this problem

@vzaliva

vzaliva commented Oct 22, 2021

Copy link
Copy Markdown
Author

@omamkaz sorry, I do not know. I think Fn+SPACE was supported in firmware. Try to boot windows and see if it works there. Perhaps you have a hardware problem.

@osamalzabidi

Copy link
Copy Markdown

@omamkaz sorry, I do not know. I think Fn+SPACE was supported in firmware. Try to boot windows and see if it works there. Perhaps you have a hardware problem.

Ok, Thanks

@izac1

izac1 commented Apr 20, 2022

Copy link
Copy Markdown

Thanks for the many insights!
Kinda works on my ThinkBook 14 G2 ITL (20VD00CNRA)
address is 3 dec and values are 0x1c, 0x1d and 0x1e for off, low, hi, respectively.
echo -n -e "\x1c" | sudo dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=3 count=1 conv=notrunc

@terr72

terr72 commented May 16, 2023

Copy link
Copy Markdown

Thanks for the many insights! Kinda works on my ThinkBook 14 G2 ITL (20VD00CNRA) address is 3 dec and values are 0x1c, 0x1d and 0x1e for off, low, hi, respectively. echo -n -e "\x1c" | sudo dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=3 count=1 conv=notrunc

How do you determine if your addresses and values are different and what they actually are?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment