Lenovo Usb Keyboard Middle Button Bug After Upgrade From Ubuntu 15 Dot 04 to 15 Dot 10
I have one of these brilliant Lenovo Thinkpad USB keyboards with trackpoint and mouse buttons. This keyboard always worked without problems. Now I upgraded my Ubuntu installation from 15.04 to 15.10. Suddenly after the upgrade the middle mouse button on the keyboard stopped working after the laptop resumes from sleep.
Currently I do not know what the exact problem is. One workaround is to pull the USB cable and reattach it. But this cannot be a long term solution so another way is needed. We need to start some script after resume. My script is inspired by https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line . At first we have to get some ID of the keyboard.
$ cat /proc/bus/input/devices
...
I: Bus=0003 Vendor=17ef Product=6047 Version=0100
N: Name="Lenovo ThinkPad Compact USB Keyboard with TrackPoint"
P: Phys=usb-0000:00:1d.0-1.8.1/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.8/4-1.8.1/4-1.8.1:1.0/0003:17EF:6047.0011/input/input33
U: Uniq=
H: Handlers=sysrq kbd event6 leds
B: PROP=0
B: EV=120013
B: KEY=1000000000007 ff800000000007ff febeffdfffefffff fffffffffffffffe
B: MSC=10
B: LED=1f
...
The ID 4-1.8 can be found here in two places. Now we know where to find the keyboard in sysfs: /sys/bus/usb/devices/4-1.8/.
Let’s build a script to restart keyboard usb device after resume. In /etc/pm/sleep.d/ you can place such kind of scripts. The following will be our script:
#!/bin/bash
#after upgrading from 15.04 to 15.10 the middle mouse button is deativated at my lenovo thinkpad keyboard
case $1 in
resume|thaw) #only start script on resume
if [ -e "/sys/bus/usb/devices/4-1.8/authorized" ]; then #if file exists (when keyboard attached)
echo 0 > /sys/bus/usb/devices/4-1.8/authorized && echo 1 > /sys/bus/usb/devices/4-1.8/authorized
notify-send -t 900 "Reload USB Keyboard because of Ubuntu 15.10 Bug"
fi
;;
esac
Now this script is started after we return from suspend to ram. And at this place we can find another bug. If you use gnome-session-quit program to suspend the above will not work. For any reason no scripts from /etc/pm/sleep.d/ will be started when resuming from suspend with gnome-session-quit. I filed a bug report for this: https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/1543769.
But If you go to suspend by directly calling “pm-suspend” all scripts are executed and our workaround is active.