Ubuntu – Lenovo ideapad brightness keys not generating any events in Ubuntu 16.04.1

16.04backlightbrightnesskeyboardlenovo

I have a new Lenovo Ideapad 500S with a fresh Ubuntu 16.04.1 running on it. Unfortunately, the brightness up/down keys don't work. (They work fine in Windows.)

Running acpi_listen shows me generated events for volume up/down keys, but not for brightness up/down. Running xev also did not give me any output for the brightness up/down keys.

After editing the GRUB_CMDLINE_LINUX_DEFAULT line in /etc/default/grub several times with options like acpi_backlight=vendor,video.use_native_backlight=1, acpi_osi=Linux and acpi_osi=, I can confirm that this changes the soft links in /sys/class/backlight/ and I currently only have intel_backlight there.

Running echo <NUM> | sudo tee /sys/class/backlight/intel_backlight/brightness works fine and changes the brightness, and so does changing it from Settings > Brightness and Lock.

Nothing inside Ubuntu seems to be able to detect these keys, so I'm not sure making any changes in the grub config will matter at all.

Please let me know if someone knows how to fix this and also if any additional information will be useful in debugging this issue.

Update:

Adding acpi_osi=Linux acpi_backlight=intel_backlight to the line in grub seems to make the brightness down key generate something in xev (though nothing in acpi_listen yet). The output is:

KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    root 0xd3, subw 0x0, time 391361, (728,884), root:(793,936),
    state 0x0, keycode 120 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3c00001,
    root 0xd3, subw 0x0, time 391368, (728,884), root:(793,936),
    state 0x0, keycode 120 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Additional outputs:

$ lspci -nnk | grep -iA2 vga
00:02.0 VGA compatible controller [0300]: Intel Corporation Sky Lake Integrated Graphics [8086:1916] (rev 07)
    Subsystem: Lenovo Skylake Integrated Graphics [17aa:3828]
    Kernel driver in use: i915_bpo

Best Answer

I finally solved this using a couple of workarounds.

The first step was making the keys detectable. I had a laptop of a similar model (Lenovo Z400) and I looked at what keycodes were generated for it. Based on that, I put this in my /etc/rc.local/:

setkeycodes e054 225 # Brightness up -> brightness up
setkeycodes e04c 224 # Brightness down -> brightness down

The second step was making the keys change the brightness. I first noticed that running xdotool key 232 and xdotool key 233 increased and decreased the brightness perfectly (including the change notification in Unity). Then I tried two things to get the brightness to work.

First, I noticed that xev now showed me the events XF86MonBrightnessUp and XF86MonBrightnessDown for the two keys, which means everything was working fine at the X level. So I simply used Ubuntu's shortcut manager and registered the two keys (which were read as their XF86 equivalents) to the xdotool commands. This worked great!

However, some weeks later, due to some packages/drivers I changed, xev stopped reporting the XF86 events and so the above method did not work. However, acpi_listen showed that video/brightnessdown and video/brightnessup events were being generated, so then, after some googling, I put the following in a new file, /etc/acpi/events/ideapad-monitor-brightness-up:

# same event as reported by acpi_listen
event=video/brightnessup BRTUP 00000086 00000000 K
action=su vivek -c "export DISPLAY=:0.0; xdotool getactivewindow && xdotool key 233 2>&1 > /tmp/log"
# The redirection into /tmp/log probably doesn't make any difference

and also an equivalent ideapad-monitor-brightness-down file with xdotool key 232 and that solved the problem. Haven't had any problems since. :)