Anyone who's used Linux on a laptop has likely encountered some less than ideal trackpad behavior.  For instance, I lived with what appeared to be a random pasting problem for months before discovering that it to be a middle mouse button 'feature'.  I'm sure that in some cases calling it a feature is warranted - but I found it infuriating.  Some times edits before committing get a little too large - and when that coincides with having accidentally pasted a semi colon into a large file with lots of other edits, hair pulling ensues.  As with most things, once we understand the problem, the fix is simple!

In this tutorial, we're going to cover getting information about the trackpad using xinput, and then cover how to enable (or disable!) each of the following:

  • Tap-to-Click
  • Natural Scrolling
  • Three finger 'middle' mouse button action

Information Gathering:

As always, let's get some info first.  Let's check out all the input devices X is aware of:

$ xinput -list
⎡ Virtual core pointer                    	    id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ SYNA2393:00 06CB:7A13 Touchpad          	id=15	[slave  pointer  (2)]
⎜   ↳ PS/2 Synaptics TouchPad                 	id=20	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	    id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Video Bus                               	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Power Button                            	id=8	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=9	[slave  keyboard (3)]
    ↳ Integrated_Webcam_HD: Integrate         	id=10	[slave  keyboard (3)]
    ↳ Intel HID events                        	id=16	[slave  keyboard (3)]
    ↳ Intel HID 5 button array                	id=17	[slave  keyboard (3)]
    ↳ Dell WMI hotkeys                        	id=18	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=19	[slave  keyboard (3)]

Pretty rich info.  Looks like it's probably a Dell, and that it has a webcam.  However what's more valuable for us here, is the ID of the track (or touch) pad: 15.

Let's get more info about it:

$ xinput -list-props 15
Device 'SYNA2393:00 06CB:7A13 Touchpad':
	Device Enabled (144):	1
	Coordinate Transformation Matrix (146):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
	libinput Tapping Enabled (297):	0
	libinput Tapping Enabled Default (298):	0
	libinput Tapping Drag Enabled (299):	1
	libinput Natural Scrolling Enabled (279):	0
	libinput Natural Scrolling Enabled Default (280):	0

...
	libinput Middle Emulation Enabled (286):	0
	libinput Middle Emulation Enabled Default (287):	0
	libinput Accel Speed (288):	0.000000
	libinput Accel Speed Default (289):	0.000000
	libinput Left Handed Enabled (293):	0
	libinput Left Handed Enabled Default (294):	0
	libinput Send Events Modes Available (264):	1, 1
	libinput Send Events Mode Enabled (265):	0, 0
	libinput Send Events Mode Enabled Default (266):	0, 0
	Device Node (267):	"/dev/input/event11"
	Device Product ID (268):	1739, 31251
	libinput Drag Lock Buttons (295):	<no items>
	libinput Horizontal Scroll Enabled (296):	1

Now we know all the possible device properties, their current values and in many cases their default values.  Pretty clearly, tapping, and natural scrolling are disabled.

Setting xinput Props:

We can set properties with -set-prop by passing the device name, the property we want to modify, and finally the value. 

Let's enable tapping:

$ xinput -set-prop 'SYNA2393:00 06CB:7A13 Touchpad' 'libinput Tapping Enabled' 1

Great!  Now let's also enable natural scrolling:

$ xinput -set-prop 'SYNA2393:00 06CB:7A13 Touchpad' 'libinput Natural Scrolling Enabled' 1

Excellent.  Now we can tap and scroll naturally.

The Button Map:

Looking through the properties available on the trackpad, nothing obviously 'middle click' related is set, and the 'Middle Emulation' property is already set to 0.  So why the three finger paste problem?

It turns out that this is a feature of the button map, everything to do with which strikes me as somewhat cryptic.  Basically, it maps button IDs to actions, but it's easier to see how it works in action.  To start, let's see how many actions xinput thinks the trackpad has:

$ xinput get-button-map 'SYNA2393:00 06CB:7A13 Touchpad'
1 2 3 4 5 6 7

Interesting, 7 different actions, or buttons.  However at this point I have no idea what each number represents, so we need to do a little further investigation.  We can use xev, a tool that dumps X events.

To use it, simply run the tool, and then try out the various mouse actions.  For instance, three finger tap on my trackpad results in the following X event:

ButtonPress event, serial 34, synthetic NO, window 0x4e00001,
    root 0x190, subw 0x4e00002, time 16996859, (58,30), root:(1214,580),
    state 0x0, button 2, same_screen YES

So button 2 is a three finger tap.

A single finger click creates the following:

ButtonPress event, serial 34, synthetic NO, window 0x4e00001,
    root 0x190, subw 0x0, time 17136691, (264,321), root:(1420,871),
    state 0x0, button 1, same_screen YES

A little bit of investigating reveals the following ID <-> Action (Button) mapping:

  • 1 <-> Single Finger Tap/Left Button Click
  • 2 <-> Three Finger Tap/Middle Mouse Button Click
  • 3 <-> Two Finger Tap/Right Button Click
  • 4 <-> Two Finger, Downward Drag
  • 5 <-> Two Finger, Upward Drag
  • 6 <-> Two Finger, Rightward Drag
  • 7 <-> Two Finger, Leftward Drag

Now what properly confused me at first, was how to either disable or change the mapping.  The solution is actually pretty straightforward, though the man page for xinput doesn't suggest it (after some reading however - the man page for libinput DOES).

Anyway.

The mapping is based on the order.  So the first number in the mapping represents what the single finger tap should do.  If it's 1, then it will produce the left click action, if it's 3 it will produce the right click action, and if it's 0 it's disabled. Put another way:

An n in the nth spot will produce the default behavior (whatever n maps to, eg. 1 => 1  means a single finger tap produces a single finger tap action).

An n in the kth spot will cause kth action to occur when the nth event is received (eg. 1 => 3 means a single finger tap produces a double finger tap action).

Disabling Three Finger Tap:

So, now we can get to back to the original goal of disabling the annoying three finger tap action.

TL;DR: To disable the middle mouse / three finger tap action, we can do the following:

$ xinput set-button-map 'SYNA2393:00 06CB:7A13 Touchpad' 1 0 3

What fun.

Persisting Our Changes

Simply making the changes we've made here will only last until you exit your active X session.  In order to make these changes permanent, we need to set them each time we launch an X session.

We can do this by placing them in some file that X reads at launch.  There are a couple different options that will work.  I've chose to use ~/.xsessionrc:

As an example, mine looks like this:

xinput -set-prop 'SYNA2393:00 06CB:7A13 Touchpad' 'libinput Tapping Enabled' 1
xinput -set-prop 'SYNA2393:00 06CB:7A13 Touchpad' 'libinput Natural Scrolling Enabled' 1
xinput set-button-map 'SYNA2393:00 06CB:7A13 Touchpad' 1 0 3

Voila!

 

# Reads: 4839