19

I am using ASUS UX303 LN, Laptop and Ubuntu Gnome 14.04 is installed on it. I cant find a way to turn on my keyboard backlight on it. The keyboard shortcut that works in windows is not working here. Please help

Pilot6
  • 90,100
  • 91
  • 213
  • 324
screenslaver
  • 367
  • 1
  • 5
  • 16
  • you must check the layout of your keyboard and change it to what fits your needs –  Jul 04 '15 at 12:50

6 Answers6

32

To enable the backlight:

echo 2 | sudo tee /sys/class/leds/asus::kbd_backlight/brightness 

The 2 at echo 2 | can be changed to a value between 0 - 3, with 3 being the brightest.

To disable the backlight, enter:

echo 0 | sudo tee /sys/class/leds/asus::kbd_backlight/brightness

The path may vary depending on laptop model and your OS. For example Lenovo Thinkpad L390 running Manjaro has /sys/class/leds/tpacpi::kbd_backlight/brightness. You can use find to see the correct path:

find /sys/class/leds -name '*kbd_backlight'
Jezor
  • 103
TellMeWhy
  • 17,484
13

Try

xset led on

or

xset led 3

This worked well with my CMSTORM (Cooler Master Storm Devastator) keyboard.

  • This worked for me. Plus, an easier way to apply this command at start up is to use Ubuntu's Startup Application and just and this command there. Worked perfectly – Thales Souza Freire Sep 18 '22 at 13:05
5

You can turn on backlight by this command

sudo tee /sys/class/leds/asus::kbd_backlight/brightness <<< 3

This will set it to maximum. The number at the end means brightness ( 0 - 3).

You can link this command to some hot key combination.

You can also read article regarding setting up Ambient Light Sensor.

Pilot6
  • 90,100
  • 91
  • 213
  • 324
  • It works when i type in, but when I add it as a custom keyboard shortcut its not working – screenslaver Jul 04 '15 at 15:17
  • 2
    This is actually another topic how to setup a script requiring sudo to a key combination. It must be answered already somewhere. I make a script and set that it does not require a password in sudoers. – Pilot6 Jul 04 '15 at 15:21
  • Works for live tech ergonomic keyboard as well. – Milind Anantwar Feb 26 '20 at 13:05
  • This gives me tee: '/sys/class/leds/asus::kbd_backlight/brightness': No such file or directory 3. Anything else I can try? – Andyc Sep 14 '20 at 17:52
  • This means that there is no backlight, or it is not supported. – Pilot6 Sep 14 '20 at 18:00
  • @Pilot6 When booting, the backlight is off and I haven't figured out a way to turn it on. I have tried all suggestions here. The strange part is: it comes automatically on to the brightest setting when the computer resumes from suspend. – Andyc Oct 04 '20 at 21:07
4

Here's how I got it solved:

#!/bin/bash
# Adjust the keyboard backlight level

shopt -s -o nounset

declare -i KBD_BACKLIGHT_MAX=`cat /sys/class/leds/asus\:\:kbd_backlight/max_brightness`
declare -i KBD_BACKLIGHT_LEV=`cat /sys/class/leds/asus\:\:kbd_backlight/brightness` 

# We need a parameter, etiher inc or dec
if [ $# -eq 0 ] ; then
   exit 192
fi 

case $1 in
-inc ) 
   # increasing:
   if [ ${KBD_BACKLIGHT_LEV} -lt ${KBD_BACKLIGHT_MAX}  ] ; then
      KBD_BACKLIGHT_LEV=${KBD_BACKLIGHT_LEV}+1
      echo ${KBD_BACKLIGHT_LEV} | tee /sys/class/leds/asus::kbd_backlight/brightness
   fi
   ;;
-dec )
   # decreasing:
   if [ ${KBD_BACKLIGHT_LEV} -gt 0 ] ; then
      KBD_BACKLIGHT_LEV=${KBD_BACKLIGHT_LEV}-1
      echo ${KBD_BACKLIGHT_LEV} | tee /sys/class/leds/asus::kbd_backlight/brightness
   fi
   ;;
esac

exit 192

Save the above script in /opt/tweaks/kbd_backlight_adjust.

Then this needs to be run with sudo from a keyboard shortcut so we must add a line to sudoers.

Use visudo and add this line to the bottom:

your_username ALL=(root) NOPASSWD: /opt/tweaks/kbd_backlight_adjust

And finally create your keyboard shortcuts using these commands for increasing and decreasing the keyboard backlight:

sudo /opt/tweaks/kbd_backlight_adjust -inc

and

sudo /opt/tweaks/kbd_backlight_adjust -dec

That should do it :-)

  • excelent ! just missing the command chmod +x /opt/tweaks/kbd_backlight_adjust to enable of script execution. – cgasp Jun 04 '16 at 22:30
  • Thank you for this script. It worked fine for me and solved my problem.Running Ubuntu 20.04 on Lenovo Thinkpad X1 Yoga Gen4 – RazTaz Jun 20 '20 at 22:21
  • What if I have no opt/tweaks directory? – Andyc Sep 14 '20 at 17:52
2

I had the same issue with an Asus ROG laptop I'd purchased. Here's what I did to fix keyboard shortcuts in general.

sudo vim /etc/default/grub

You’ll find this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Simply add on to the end of it:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi="

Save, Exit and Reboot

Zanna
  • 70,465
Matt O.
  • 543
  • 2
  • 9
  • This is not working for me on an ASUS ROG G401IU with Ubuntu 20.04. I tried with both acpi_osi=, acpi_osi=linux with and without acpi_backlight=vendor. When I reboot the computer, the keyboard backlight is off again. – Andyc Sep 06 '20 at 06:11
-1

You can easily update kernel using "Ukku Kernel Update Utility" https://github.com/teejee2008/ukuu Updates to 5.x kernel solve all my problem on Asus UX433F (backlight, sound).

dmgl
  • 253
  • 2
  • 4
  • 9