Missed Touchpad Button Clicks

I had gotten this laptop as a gift/hand-me-down from someone else. Since the first thing I did was install Linux, I hadn’t thought otherwise that the buttons hadn’t been treated to well: left-click was very stubborn, often missing on some very obvious pushes. The action/response of the button resembled a sticky button. Because right-click was better, I created a script that would switch/toggle left and right click. I toggled it twice to test it (so that it reverted back to the original) when and found that left-click was working normally. Not sure why this fixed the problem and have yet to see another problem like this but I’m glad it’s good again. I created a script to quickly do this then added .desktop file to have it load on Login. The script:

#!/bin/bash
# Touchpad-button-fix - toggles left and right mouse/touchpad buttons and back
# Again (fixes issue with missed touchpad buttons clicks)
# Detect mouse button position, switch mouse button position, then switch back
for l in {1..2}; do
state=$(xmodmap -pp | sed -n '5p' | awk '{ print $2 }') # detect button posit.
if [ "$state" == "1" ]; then
xmodmap -e "pointer = 3 2 1" &> /dev/null
sleep 2
else
xmodmap -e "pointer = 1 2 3" &> /dev/null
fi
done

Then I created a desktop file touchpad-button-fix.desktop in ~/.config/autostart to start it on Login:

[Desktop Entry]
Type=Application
Exec=/home/todd/.scripts/bugfixes/touchpad-button-fix
Icon=mousepad
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Touchpad Button Fix
Comment=Switches touchpad/mouse buttons then back again (to fix missed touchpad button click bug)

Additional, the touchpad button may revert to it’s original behavior after resuming from sleep. To run the script upon resume it will need to be defined to pm-utils. Put this in /etc/pm/sleep.d/90_touchpad-button-fix:

#!/bin/sh
# Switch touchpad/mouse buttons then back again to fix
# missing touchpad button presses bug
case "$1" in
resume | thaw )
export DISPLAY=:0
su -c - todd /home/todd/.scripts/bugfixes/touchpad-button-fix
;;
esac

Then make them executable:

sudo chmod +x ~/.config/autostart/touchpad-button-fix.desktop
sudo chmod +x /etc/pm/sleep.d/90_touchpad-button-fix

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s