0

Being aware of that this is partially a known issue, since each is individual and different, the problem is as following:

On my Lenovo Laptop with Linux Mint the backlight cannot be set using Fn+F6/F7. These keys are not detected at all, neither by xev nor by acpi_listen. However other key combinations like Fn+F3 for volume up is detected by both commands. So it is a more low-level issue, I am afraid. On the other hand, this works well:

  • echo 10000 | sudo tee /sys/class/backlight/intel_backlight/brightness and as well
  • with the GUI slider in mate-power-preferences works perfectly.
  • xdotool key 232 or xdotool key XF86MonBrightnessDown

More detailed:

  • I tried many boot combinations (yes I updated GRUB and did reboot, as described in this troubleshooting wiki.ubuntu.com Debugging/Backlight)
  • I tried adding files in /usr/share/X11/xorg.conf.d/ as recommended (80-backlight.conf using both "Backlight" "ideapad" and "intel_backlight", or 20-intel.conf)

uname -a yields: Linux Lenovo-V14-G2-ITL 5.8.0-53-generic #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

These are the available backlights (which can be written using cat)

$ ls /sys/class/backlight/
ideapad  intel_backlight

This is my current configuration

$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-5.8.0-53-generic root=/dev/mapper/vgmint-root ro pcie_aspm=force acpi_osi=Linux acpi_backlight=vendor quiet splash

I tried these (as well individually and with many combinations, only visible effect is that the output of ls /sys/class/backlight/ is changing)

GRUB_CMDLINE_LINUX="pcie_aspm=force acpi_osi=linux acpi_backlight=vendor video.use_native_backlight=1"
3
  • Not sure, but if xev doesn't register your keypresses, I don't think there's much you can do. I guess you have two options: 1) Figuring out why xev does not register these keys; or 2) use different keys to bind a command (I had best experiences with xbacklight).
    – pfnuesel
    May 15, 2021 at 18:09
  • xev not registering keypress might be more common than I thought, see e.g. here: unix.stackexchange.com/a/584299/58056
    – pfnuesel
    May 15, 2021 at 18:11
  • The behaviour is similar to this askubuntu.com/questions/830948/… however I am stuck at the transition to the step where xev detects the keys . xdotool key 232 works well! And xmodmap -pke shows the brightness keys but how do I get the scancodes? With getkeycodes I see that there is not an entry for keycode=232 (so there is no scancode associated with it?)
    – camel
    May 15, 2021 at 19:07

4 Answers 4

2

I like to control backlight with use of the light utility (in Ubuntu, it is in the package light).

So on sway, Ubuntu, I did this:

sudo apt install light
vim .config/sway/config

Add these lines somewhere in .config/sway/config (or in /etc/sway/config if you have nothing in your home):

#
# Backlight controll using thinkpad Fn+F5 and Fn+F6
#
    # Increase and decrease backlight in 4% steps
    bindsym XF86MonBrightnessUp exec sudo light -A 4
    bindsym XF86MonBrightnessDown exec sudo light -U 4

In case, you need to be root for using light, these commands would point you to solution:

light -A 5 -v 3
ls -alh /sys/class/backlight/intel_backlight/brightness
sudo usermod -aG video $USER
0

Sorry, but I cannot leave comments so I have to use answer. What Lenovo model is it?

See if this works (and, as always, make a backup of any configuration file before modifying it):

  1. echo options hid_apple fnmode=0 | sudo tee -a /etc/modprobe.d/hid_apple.conf
  2. sudo update-initramfs -u
  3. Reboot

EDIT: If fnmode=0 doesn't work, you can try fnmode=2.

2
  • It's a Lenovo machine, probably a V14 G2-ITL as the hostname suggests. Why do you think options for an Apple keyboard would work here?
    – Freddy
    May 15, 2021 at 19:16
  • I have had the same problem with a layered keyboard (none of the my products are Apple, either) where some of the buttons didn't work when I pressed Fn. Changing the conf file and updating the initramfs (and rebooting) worked for me. Thought it might be worth a shot for you as well. Cheers.
    – telometto
    May 15, 2021 at 19:26
0

What I do with mine:

#!/bin/bash

# sputnick 2023

devvideo=$(xrandr | awk '$2 == "connected"{print $1;exit}')

if ! val=$(cat ~/.config/xrandr/brightness 2>/dev/null); then
    mkdir -p ~/.config/xrandr
    echo 0.90 > ~/.config/xrandr/brightness
    val=0.90
fi

case $1 in
    -) val="0$(bc <<< $val-0.05)"  ;;
    +) val="0$(bc <<< $val+0.05)"  ;;
esac

if ((${val#*.} <= 20 || ${val#*.} >= 100 )); then
    echo >&2 ERR
    exit 1
fi

echo $val | tee ~/.config/xrandr/brightness
exec xrandr --output $devvideo --brightness +$val

then you set a keyboard shorthand to run this script in your Window Manager settings. Chosen Ctrl+fn6 and Ctrl+fn7.

The mandatory parameter is + or -. Let's KISS

0

Faced with a similar problem on...

  • i3
  • 6.5.9-arch2-1
  • Lenovo IdeaPad 5 Pro 14ACN6

... I found that while xev does not identify the function keys I can bind them ...

    # backlight control
    bindsym XF86MonBrightnessUp exec display.sh 0.1
    bindsym XF86MonBrightnessDown exec sh display.sh -0.1

...to a very simple script ....

#!/bin/bash

increment="$1"
brightness=$(xrandr --verbose | sed -n "/eDP/{n;n;n;n;n;s/.*: //p}")
xrandr --output eDP --brightness $(echo "$brightness + $increment " | bc)

As you can probably guess, I also had issues writing to the '/sys/' backlight controls and so used a nasty hack with xrandr.

Not quite sure how to implement keybindings in Mint (maybe like this?) but like you I tried many things and since binding worked it was good enough.

Update - fix for the brightness keys

I found that installing acpi_call-dkms resolved my Fn key issue with brightness control thanks to the Archwiki. You may find an equivalent in your repository.

As an aside - who needs the brightness keys anyway?

I found the above fix while fiddling to use my webcam as a sensor and automatically control the screen brightness (via systemd timer, service and script), but came across clight-gui over at Github which allows custom independent brightness ramps on battery and AC for both keyboard and backlight driven by ambient light. Solved all of my needs.

My thanks to @FedeDP and @nullobsi over at Github.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .