Skip to content

Instantly share code, notes, and snippets.

@latusikl
Last active August 8, 2019 19:46
Show Gist options
  • Save latusikl/302bd843d64d3b7174d19e890699e9c2 to your computer and use it in GitHub Desktop.
Save latusikl/302bd843d64d3b7174d19e890699e9c2 to your computer and use it in GitHub Desktop.
Zenbook UX550GE Ubuntu 18.04 LTS

Not working backlight button (Zenbook UX550GE Ubuntu 18.04 LTS)

After instalation you can adjust yours keyboard backlight only via settings (Settings->Power->Keyboard Backlight) but the key is not responding.

For now I was able to create bash script which controlls backlight in a similar way it's done in Windows for that laptop. Thing left to do is to assign executing this script to the button which I'm currently working on.


  • How is backlight controlled?

You can find backlight info and variable which controlls it at: /sys/class/leds/asus::kbd_backlight Current brightnes is in variable: "brightness" and should be in range of 0 to value of variable "max_brightness" You can controll this variable via Shell script.

  • Creating shell script.

There is a ready script for controlling backlight. You should find it in /ect/acpi in my laptop it was called: "asus-keyboard-backlight.sh". You can even call it:

sudo /etc/acpi/asus-keyboard-backlight.sh

However it wasn't working as I wanted and as backlight works in Windows (increasing backlight from 0 to level 3 and then again to zero).

I decided to write another script based on this one which will allow me to run backlight only by typing "backlight" in terminal. If you want to do that as well please follow steps below.


  • How to run a script just by typing backlight. This procedure I described generally in another gist, you can find it here. You can also find there how to run script without sudo password- you will need that too.

  • Creating a script To make it work you will need to create two scripts:

  1. Script containing the procedure.

To do that you need to create file and make it executable. In choosen location or (in bin folder in ~ catalog if you follow procedure to run it by typing "backlight") type:

touch backlightScript
chmod +x backlightScript

After that using your favourite editor (gedit/nano/vim...) write in the file.

#!/bin/bash
#Directory where you can find info about keyboard backlight
KEYS_DIR=/sys/class/leds/asus\:\:kbd_backlight

#If directory does not exist exit
test -d $KEYS_DIR || exit 0

MIN=0
MAX=$(cat $KEYS_DIR/max_brightness)
VAL=$(cat $KEYS_DIR/brightness) #Current backlight value

if [ $VAL -eq $MAX ]
then
VAL=$MIN
else
VAL=$((VAL+1))
fi
echo $VAL > $KEYS_DIR/brightness

And that can be it you can run this script by typing in terminal:

sudo ./backlightScript

If you want to use it by typing just "backlight" I recommend to create second script:

touch backlight
chmod +x backlight

And write in it:

#!/bin/bash
sudo ~/bin/backlightScript

After doing the steps from the link (adding a script to .bashrc PATH and making backlightScript executable without passing sudo password) you should be able to controll backlight by typing "backlight" in terminal.


Thing left to do is to assign script to the key.

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