How to Configure Touchpad Buttons?

My laptop has a touchpad with 4 buttons (2 top and 2 bottom). When I was using Windows, it was easy with the Synaptics driver app to configure the buttons for various purposes.

I found the KDE system settings for Mouse and Touchpad limited in configurations and I am such a beginner with Linux so don’t know how to create “scripts” to make changes.

Can someone guide me step by step as I know Linux allows for a lot of configurations except I am still new to picking up the skills to do so? Thanks.

welcome to manjaro and linux!

any fix depends on getting to know what your system is before anything can be recommended.

please provide output of following commands in the terminal;

$ inxi -v7azy

and

$ sudo libinput list-devices

Thanks for responding.

The output as follows:

$ inxi -v7azy
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = “”,
LC_ALL = (unset),
LC_ADDRESS = “en_NZ.UTF-8”,
LC_NAME = “en_NZ.UTF-8”,
LC_MONETARY = “en_NZ.UTF-8”,
LC_PAPER = “en_NZ.UTF-8”,
LC_IDENTIFICATION = “en_NZ.UTF-8”,
LC_TELEPHONE = “en_NZ.UTF-8”,
LC_MEASUREMENT = “en_NZ.UTF-8”,
LC_TIME = “en_NZ.UTF-8”,
LC_NUMERIC = “en_NZ.UTF-8”,
LANG = “wbp_AU.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
System:
Kernel: 5.10.164-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 12.2.1
parameters: BOOT_IMAGE=/vmlinuz-5.10-x86_64
root=UUID=49b4eb11-5a43-42d8-92bc-ece68525db2c rw quiet apparmor=1
security=apparmor resume=UUID=f9967c15-c88f-4607-9214-99af95500157
udev.log_priority=3
Desktop: KDE Plasma v: 5.26.5 tk: Qt v: 5.15.8 wm: kwin_x11 vt: 1 dm:
1: LightDM v: 1.32.0 note: stopped 2: SDDM Distro: Manjaro Linux
base: Arch Linux
Machine:
Type: Laptop System: Hewlett-Packard product: HP EliteBook 8460p v: A0001D02
serial: Chassis: type: 10 serial:
Mobo: Hewlett-Packard model: 161C v: KBC Version 97.4E
serial: BIOS: Hewlett-Packard v: 68SCF Ver. F.65
date: 04/06/2017
Illegal division by zero at /usr/bin/inxi line 7820.


$ libinput list-devices
Device: SynPS/2 Synaptics TouchPad
Kernel: /dev/input/event19
Group: 9
Seat: seat0, default
Size: 95x41mm
Capabilities: pointer
Tap-to-click: disabled
Tap-and-drag: enabled
Tap drag lock: disabled
Left-handed: disabled
Nat.scrolling: disabled
Middle emulation: n/a
Calibration: n/a
Scroll methods: *two-finger edge
Click methods: none
Disable-w-typing: enabled
Disable-w-trackpointing: enabled
Accel profiles: flat *adaptive
Rotation: n/a

need to set your locale
open /etc/locale.gen

$ sudo nano /etc/locale.gen 

and un-comment line reading en_NZ.UTF-8 UTF-8

run

$ sudo locale-gen

for a touchpad of laptop made in 2012, that probably is it. top 2 buttons will function just as the bottom 2.

https://wiki.archlinux.org/title/Laptop/HP

has no mention of available fix, do a google search on possible fixes, but dont waste too much time

Still trying :slight_smile:

Had been using the Synaptics app on Windows with no problem all this time but Windows has other issues with my older hardware, hence I’m going Linux where I still have a chance to modify my own system to a degree :slight_smile:

What do they currently do?
What do you want them to do?

I don’t have any real experience with this. There might be something specific to your use case/touchpad, but I have no idea if there is.

Generally you can find out what X sees when you press the buttons, then you can re-map them to keyboard combinations and set some keyboard shortcuts to match.

Doesn’t sound like it, but if you just want to re-arrange them then try xinput.

Touchpad Synaptics - ArchWiki
Mouse buttons - ArchWiki
xinput - ArchWiki

Currently, the top two and bottom two do the same, left for left click and right for right.

The KDE touchpad settings does not have an option for middle-button click which I want for opening web links on a new tab. I want to only use the top right button on my touchpad for that instead of two-finger tapping which is finicky and you have to time it right for two fingers to touch the pad at the same time. Seldom get it right the first time.

I’ve also played around with ‘xinput’ as well as modifying the 30-touchpad.conf file in /etc/X11/xorg.conf.d/ but I’m still not getting the result I want.

usually 3-finger tap achieves that with stock settings. i dont know, whether the difficulty of mutiple-finger tapping is something with your touchpad but it is not something difficult on most touchpads i’ve tried old and new.

I’ve had a little play around. Here’s an example.

This is my touchpad.

$ xinput  
# for brevity I've only included the touchpad here
↳ SynPS/2 Synaptics TouchPad              	id=14	[slave  pointer  (2)]

I’ve used the id, you can also use the name but you need to put it in quotes like below.

$ xinput get-button-map 14
1 2 3 4 5 6 7

Post the button map here for reference and so we can help. To swap the left and right buttons we do this.

xinput set-button-map 14 3 2 1 4 5 6 7

It may require a bit of trail and error to get the correct map for your needs. It sounds like you should see two 1’s (left click) and two 3’s (right click), it should (hopefully) be a matter of playing around with those. Middle click is 2, so find a 3 and replace it with 2.

This config is only temporary so we’ll need to make it permanent once we’ve figured it out. The easiest way to do this is to add it to ~/.xinitrc.

echo xinput set-button-map \"SynPS/2 Synaptics TouchPad\" 3 2 1 4 5 6 7 >> ~/.xinitrc

I used the name here because unlike the id it won’t change. Obviously change the map to suit your needs. This needs to be done for each user. Alternatively you can use a systemd user service.

If you prefer a systemd service
[Unit]
Description=Set button map for touchpad

[Service]
Type=oneshot
ExecStart=sleep 1 # wait for X
ExecStart=/usr/bin/xinput set-button-map "SynPS/2 Synaptics TouchPad" 3 2 1 4 5 6 7

[Install]
WantedBy=default.target

If you want it available for all users then save it as:
/etc/systemd/user/touchpad.service

If you only have 1 user or if you want different maps for each user then save it as:
~/.config/systemd/user/touchpad.service

Either way, run this command for each user that wants the buttons switched. If you change the name of the file, then adjust the command accordingly.

systemctl enable --now --user touchpad.service

Thanks, DMT.

Mine comes up:

$ xinput get-button-map 16
1 2 3 4 5 6 7 8 9 10 11 12

I have played around with “xinput set-button-map 16” but the result still returns as above.

Let’s check the config higher up.

xev -event button | grep button

What do I do with the event window?

Click in it and press the buttons, paste the result here.

$ xev -event button | grep button
xev: warning: could not set default locale
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES
    state 0x0, button 3, same_screen YES
    state 0x400, button 3, same_screen YES
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES
    state 0x0, button 3, same_screen YES
    state 0x400, button 3, same_screen YES
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES
    state 0x0, button 2, same_screen YES
    state 0x200, button 2, same_screen YES
    state 0x0, button 2, same_screen YES
    state 0x200, button 2, same_screen YES
    state 0x0, button 2, same_screen YES
    state 0x200, button 2, same_screen YES
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES
    state 0x0, button 3, same_screen YES
    state 0x400, button 3, same_screen YES
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES
    state 0x0, button 3, same_screen YES
    state 0x400, button 3, same_screen YES
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES
    state 0x0, button 3, same_screen YES
    state 0x400, button 3, same_screen YES
    state 0x0, button 1, same_screen YES
    state 0x100, button 1, same_screen YES

From the results, on the touchpad (same for top and bottom two buttons):
Button 1 = left click
Button 3 = right click

On the mouse, the middle button = Button 2.

So, for the touchpad, I should change button 3 to Button 2?

But the command “xinput set-button-map "SynPS/2 Synaptics TouchPad"” did not seem to effect any change.

Perhaps the Xorg server is taking instructions from libinput instead of Synaptics driver? What do you reckon?

The button map shows all the buttons are mapped separately, xev shows them doubled up, so the re-mapping is being done either in X or somewhere in between. Unfortunately I don’t know exactly how/where the mouse buttons are being re-mapped, and my pad only has 2 buttons so I can’t test here.

Yes try that and every other place (except 1/left and 2/middle), one at a time, until you get the correct place. I’d start with 3, 10, 11 and 12. If none of them work them we need to figure out what’s re-mapping the buttons.

That command is missing the button map. Here’s one with 3 replaced.

xinput set-button-map "SynPS/2 Synaptics TouchPad" 1 2 2 4 5 6 7 8 9 10 11 12

The synaptics driver is deprecated in favour of libinput. It should be using libinput, you can check with this.

cat /var/log/Xorg.0.log | grep libinput | grep Syn

It may be easier to use the emulate 3 buttons option, it emits middle click when left and right are pressed simultaneously. You should be able to set it from the GUI.

When you post output could you please select it and press the </> button to enclose it in code tags. It makes it easier to read.

Finally, it worked but with a slight alternative to your suggestion. Thank you for persisting with me and your patience, very much appreciated.

Your suggested command works:

xinput set-button-map "SynPS/2 Synaptics TouchPad" 1 2 2 4 5 6 7 8 9 10 11 12

…but writing to .xinitrc and restarting did not retain the desired effect.

I found out that I could create a .xprofile file and leave it in my /home/(user) folder and it works now.

The script on the .xprofile as follows:

#!/bin/sh

# Set up the Xresources
xrdb -merge ~/.Xresources

# Set up the touchpad button mapping
xinput set-button-map "SynPS/2 Synaptics TouchPad" 1 2 2 4 5 6 7 8 9 10 11 12

# Launch the Plasma Desktop Environment
exec startplasma-x11
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.