You are not logged in.

#1 2022-03-01 20:42:41

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

[SOLVED] Force loading Synaptics touchpad driver on X w/ shell script

I've been attempting to solve an issue on my ThinkPad T420 laptop, namely trying to force X to use the Synaptics touchpad driver instead of evdev. The main issue is that my touchpad is sometimes (actually quite frequently) detected as a mouse by the system instead of a touchpad - as demonstrated with xinput below. Previous searches online for solutions give nothing other than "file a bug report" and "update your kernel" (I am using the newest linux-zen kernel - the newest version of linux and linux-lts kernels don't make a difference), so I had to find a workaround through modprobe. Reloading the psmouse module will fix the issue half the time, half the time it will do nothing. As a result, I've been attempting to write a shell script executed by a systemd service on boot to repeatedly reload the psmouse module on boot until the Synaptics driver has been loaded correctly, but to no avail. My main difficulty is writing the condition to stop the script once the Synaptics driver has been loaded - having tried to grep Xorg.0.log and using the exit status of synclient has not worked thus far - any ideas?

Current shell script:

kevin@Kevin-T420 /usr/bin % cat touchpad-driver-fix.sh 
#!/bin/sh
until grep "Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'" /var/log/Xorg.0.log
do
    modprobe -r psmouse
    modprobe psmouse
    echo "reloading psmouse..."
done

systemd service:

kevin@Kevin-T420 /etc/systemd/system % cat touchpad-driver-fix.service                  
[Unit]
Description=Force loading of Synaptics driver over evdev

[Service]
Type=simple
ExecStart=/usr/bin/touchpad-driver-fix.sh

[Install]
WantedBy=multi-user.target

xinput when touchpad registered as mouse:

kevin@Kevin-T420 /etc/X11/xorg.conf.d % xinput list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ PS/2 Generic Mouse                      	id=12	[slave  pointer  (2)]
⎜   ↳ Logitech Wireless Mouse                 	id=10	[slave  pointer  (2)]
⎜   ↳ Logitech Wireless Keyboard PID:4023     	id=9	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=8	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=11	[slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                  	id=13	[slave  keyboard (3)]

When properly registered as a touchpad:

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ Logitech Wireless Mouse                 	id=10	[slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad              	id=12	[slave  pointer  (2)]
⎜   ↳ Logitech Wireless Keyboard PID:4023     	id=9	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=8	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=11	[slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                  	id=13	[slave  keyboard (3)]

My /etc/X11/xorg.conf.d files are working correctly, and they are listed below if they may be of use for providing help:

kevin@Kevin-T420 /etc/X11/xorg.conf.d % cat 10-evdev.conf 
#
# Catch-all evdev loader for udev-based systems
# We don't simply match on any device since that also adds accelerometers
# and other devices that we don't really want to use. The list below
# matches everything but joysticks.

Section "InputClass"
        Identifier "evdev pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection
kevin@Kevin-T420 /etc/X11/xorg.conf.d % cat 70-synaptics.conf 
# Example xorg.conf.d snippet that assigns the touchpad driver
# to all touchpads. See xorg.conf.d(5) for more information on
# InputClass.
# DO NOT EDIT THIS FILE, your distribution will likely overwrite
# it when updating. Copy (and rename) this file into
# /etc/X11/xorg.conf.d first.
# Additional options may be added in the form of
#   Option "OptionName" "value"
#
Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"
# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
        MatchDevicePath "/dev/input/event*"
        Option "TapButton1" "1"
        Option "TapButton2" "3"
        Option "TapButton3" "2"
        Option "VertEdgeScroll" "on"
        Option "VertTwoFingerScroll" "on"
        Option "HorizEdgeScroll" "on"
        Option "HorizTwoFingerScroll" "on"
        Option "AccelFactor" "0"
        Option "MinSpeed" "1"
        Option "MaxSpeed" "1"
EndSection

Section "InputClass"
        Identifier "touchpad ignore duplicates"
        MatchIsTouchpad "on"
        MatchOS "Linux"
        MatchDevicePath "/dev/input/mouse*"
        Option "Ignore" "on"
EndSection

# This option enables the bottom right corner to be a right button on clickpads
# and the right and middle top areas to be right / middle buttons on clickpads
# with a top button area.
# This option is only interpreted by clickpads.
Section "InputClass"
        Identifier "Default clickpad buttons"
        MatchDriver "synaptics"
        Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
        Option "SecondarySoftButtonAreas" "58% 0 0 15% 42% 58% 0 15%"
EndSection

# This option disables software buttons on Apple touchpads.
# This option is only interpreted by clickpads.
Section "InputClass"
        Identifier "Disable clickpad buttons on Apple touchpads"
        MatchProduct "Apple|bcm5974"
        MatchDriver "synaptics"
        Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
EndSection

Last edited by Vectorlocity (2022-03-02 00:19:29)

Offline

#2 2022-03-01 22:14:48

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,057

Re: [SOLVED] Force loading Synaptics touchpad driver on X w/ shell script

Does

psmouse.synaptics_intertouch=1

help? (In doubt by allowing you to blacklist i2c_hid)

Grepping the xorg log before X11 starts won't work. Try

libinput list-devices

Offline

#3 2022-03-01 22:57:12

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Force loading Synaptics touchpad driver on X w/ shell script

The kernel option you gave unfortunately doesn't work.
Before you replied I also tried dmesg | grep "synaptics", but that also didn't work in that if the Synaptics driver didn't load first time it would be stuck perpetually reloading the psmouse module and because of that my touchpad would not work at all.
I also edited the service file to change multi-user.target to graphical.target:

kevin@Kevin-T420 /etc/systemd/system % cat touchpad-driver-fix.service  
[Unit]
Description=Force loading of Synaptics driver over evdev

[Service]
Type=simple
ExecStart=/usr/bin/touchpad-driver-fix.sh

[Install]
WantedBy=graphical.target

Using libinput list-devices gives the same behaviour as attempting to grep dmesg, here's my shell script file:

kevin@Kevin-T420 /etc/systemd/system % cat /usr/bin/touchpad-driver-fix.sh 
#!/bin/sh
until (libinput list-devices | grep "SynPS/2")
do
    modprobe -r psmouse
    modprobe psmouse
    echo "reloading psmouse..."
done

I'm pretty much a newbie to shell script beyond the basics, so I don't know if I'm doing anything wrong here.
Upon closer inspection when my shell script seems to perpetually loop, it seems that whether my touchpad is detected as a mouse or actually a touchpad is completely random each time the psmouse module is reloaded, as evidenced below:

kevin@Kevin-T420 /etc/systemd/system % grep "Using input driver" /var/log/Xorg.0.log
[     5.418] (II) Using input driver 'evdev' for 'Power Button'
[     5.437] (II) Using input driver 'evdev' for 'Video Bus'
[     5.439] (II) Using input driver 'evdev' for 'Sleep Button'
[     5.446] (II) Using input driver 'evdev' for 'Logitech Wireless Keyboard PID:4023'
[     5.448] (II) Using input driver 'evdev' for 'Logitech Wireless Mouse'
[     5.451] (II) Using input driver 'evdev' for 'AT Translated Set 2 keyboard'
[     5.456] (II) Using input driver 'evdev' for 'ThinkPad Extra Buttons'
[     5.496] (II) Using input driver 'evdev' for 'Logitech Wireless Mouse'
[     5.498] (II) Using input driver 'evdev' for 'Logitech Wireless Keyboard PID:4023'
[     6.296] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[     7.295] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[     8.995] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    10.722] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    11.723] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    13.429] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    14.419] (II) Using input driver 'synaptics' for '"SynPS/2 Synaptics TouchPad"'
[    15.419] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    16.425] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    18.112] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    19.135] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    20.863] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    22.562] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    23.572] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    24.607] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    26.329] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    27.313] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    28.319] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    30.036] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    31.739] (II) Using input driver 'evdev' for 'PS/2 Generic Mouse'
[    32.727] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'
[    33.725] (II) Using input driver 'synaptics' for 'SynPS/2 Synaptics TouchPad'

Offline

#4 2022-03-01 23:30:11

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Force loading Synaptics touchpad driver on X w/ shell script

Alternatively, to solve my issue I could simply remove the evdev configuration file from /etc/X11/xorg.conf.d, but then I'd like to somehow change the default input driver for any mouse from libinput to evdev - and I can't seen to find a way to do that yet.
The whole original goal of moving away from the libinput driver for all of this was to completely disable pointer acceleration, after reading on some post here that libinput did not support truly flat acceleration profiles and only had a half-arsed implementation of them. I would also be fine with using evdev as my touchpad driver, if it were not for the lack of features such as 2-finger scrolling, edge scrolling, among others that Synaptics brings.

Offline

#5 2022-03-02 00:18:34

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Force loading Synaptics touchpad driver on X w/ shell script

Appears to be solved now, after adding a sleep 1 statement to my shell script - maybe the commands inside the until loop were being executed too fast for the actual condition to be evaluated beforehand... although that theory doesn't seem plausible. At least it appears that the Synaptics driver is being consistently loaded on boot now, rather than evdev sometimes. There is a short delay before the cursor becomes active on the login screen, but I can live with that.

Final shell script:

kevin@Kevin-T420 /etc/systemd/system % cat /usr/bin/touchpad-driver-fix.sh 
#!/bin/sh
until libinput list-devices | grep "SynPS/2"
do
    modprobe -r psmouse
    modprobe psmouse
    echo "reloading psmouse..."
    sleep 1
done

Final systemd unit file (changed back to multi-user.target):

kevin@Kevin-T420 /etc/systemd/system % cat touchpad-driver-fix.service  
[Unit]
Description=Force loading of Synaptics driver over evdev

[Service]
Type=simple
ExecStart=/usr/bin/touchpad-driver-fix.sh

[Install]
WantedBy=multi-user.target

Offline

Board footer

Powered by FluxBB