Tuesday 4 February 2020

Ubuntu Linux on Lenovo Yoga S940: volume control key press repeats until volume goes to maximum or minimum

I encountered a strange  problem with functional keys for volume control on my Lenovo Yoga S940 under Ubuntu Linux 19.10. Whenever I would increase or  decrease the sound volume if I hold the key pressed long enough for the OS to register the  repeat  it would repeat the key press even after I have  released the button until the volume goes to 100% or 0% correspondingly to the key which was  pressed. Be careful with experimenting, 100% volume can damage your hearing! Author of the blog is not responsible for  any damage experiments may cause.

The issue was present in both modes of functional keys i.e. when the multimedia control is primary and F1-F12 are accessible through Fn key or opposite. One can change it in BIOS. I personally prefer when F1-F10 is set as primary and multimedia keys require Fn. Interestingly only volume control keys were affected, screen brightness control worked as expected.

Search on the internet lead me to this post on Stack Overflow. After reading the post I tried to press any other key while volume was going up and down and the additional keypress stopped the process which  reassured me that I had the same problem.

I followed  the advice posted  on Stack Overflow. Obviously I had another  model of the laptop and I had to edit the hardware  info.

The command "cat /sys/class/dmi/id/modalias" gave me the information about my hardware. I created a file /lib/udev/hwdb.d/99-keyboard-lenovo-vol-fix.hwdb
and inserted following lines:
"# Fix for volume keys on Lenovo Yoga S940
evdev:atkbd:dmi:bvn*:bvr*:svnLENOVO:pn81Q7*:pvrLenovoYogaS940*
 KEYBOARD_KEY_a0=!mute
 KEYBOARD_KEY_ae=!volumedown
 KEYBOARD_KEY_b0=!volumeup"

 The next step was to run these two commands as root:
systemd-hwdb update
udevadm trigger --verbose --sysname-match="event*"


Now volume control buttons work as expected.

The model identifier  of the laptop with 8th gen CPU was pn81Q7, for 10th gen it seems to be pn81Q8. One can try to use pn*

No comments: