# Dell XPS 15 9550 Arch Linux Trackpad Multitouch Clicks and Gestures with libinput (and i3-wm)



_**EDIT (1/24/2017):** I've switched to [Wayland](https://wayland.freedesktop.org/) and [sway](http://swaywm.org/) on my 9550, but I still use `libinput-gestures` for trackpad gestures. However, my `libinput-gestures` config has changed slightly to accomodate `sway`. You can see the always-up-to-date version [here](https://github.com/Spirotot/dotFiles/blob/arch/.config/libinput-gestures.conf)!_

By cobbling together a few different pieces and projects, we are able to get some basic gestures working on the Dell XPS 15 9550 trackpad, including:

* 2-finger vertical and horizontal scrolling
* 2- and 3-finger clicking
* 3- and 4- finger swiping

In this post we will cover the steps necessary to enable these gestures on the trackpad. We will then cover some information about configuring hooks/scripts to get the gestures to actually do useful things in the [i3 window manager](https://i3wm.org/), like changing workspaces and whatnot. Those instructions can be adopted to most any window manager/desktop environment. It is assumed that the reader is running an up-to-date Arch Linux installation with the X display server, but these instructions will probably be relatively easily adaptable to other Linux distributions as well.

# Required Software

Install the requisite software from the Arch respositories if it is not already (I believe these were installed by default on my Arch system, but this may not be the case for yours): 

```bash
pacman -S libinput x86-input-libinput xorg-xinput xdotool
```

If you did not already have these packages installed, you will need to restart your display manager after installation. Ensure that `libinput` is detecting devices by running:

```bash
libinput-list-devices
```

If you see no devices, you may need to disable/uninstall another driver (i.e. Synaptics) that is taking precedence over `libinput` and restart your display manager once again. See the [libinput ArchWiki page](https://wiki.archlinux.org/index.php/Libinput) for more details.

We'll also need to install [libinput-gestures](https://github.com/bulletmark/libinput-gestures). Follow the installation instructions in that README.

# `xinput` Configuration

Find the `id` for your XPS 9550's trackpad:

```bash
$ xinput list | grep Touchpad
⎜   ↳ DLL06E4:01 06CB:7A13 Touchpad           	id=12	[slave  pointer  (2)]

```

In my case, the `id` is `12`. Once you have the `id`, you can list the configurable properties for the device:

```bash
$ xinput list-props 12
Device 'DLL06E4:01 06CB:7A13 Touchpad':
	Device Enabled (139):	1
	Coordinate Transformation Matrix (141):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
	libinput Tapping Enabled (275):	0
	libinput Tapping Enabled Default (276):	0
	libinput Tapping Drag Enabled (277):	1
	libinput Tapping Drag Enabled Default (278):	1
	libinput Tapping Drag Lock Enabled (279):	0
	libinput Tapping Drag Lock Enabled Default (280):	0
	libinput Accel Speed (281):	1.000000
	libinput Accel Speed Default (282):	0.000000
	libinput Natural Scrolling Enabled (283):	1
	libinput Natural Scrolling Enabled Default (284):	0
	libinput Send Events Modes Available (259):	1, 1
	libinput Send Events Mode Enabled (260):	0, 0
	libinput Send Events Mode Enabled Default (261):	0, 0
	libinput Left Handed Enabled (285):	0
	libinput Left Handed Enabled Default (286):	0
	libinput Scroll Methods Available (287):	1, 1, 0
	libinput Scroll Method Enabled (288):	1, 0, 0
	libinput Scroll Method Enabled Default (289):	1, 0, 0
	libinput Click Methods Available (290):	1, 1
	libinput Click Method Enabled (291):	0, 1
	libinput Click Method Enabled Default (292):	1, 0
	libinput Disable While Typing Enabled (293):	1
	libinput Disable While Typing Enabled Default (294):	1
	Device Node (262):	"/dev/input/event14"
	Device Product ID (263):	1739, 31251
	libinput Drag Lock Buttons (295):	<no items>
	libinput Horizonal Scroll Enabled (264):	1
```

Note the first line of output, containing the `Device` string. In my case, it's `DLL06E4:01 06CB:7A13 Touchpad`. Using the numerical `id` is nice when you're manually typing commands on the command line, but `xinput` will allow us to use `DLL06E4:01 06CB:7A13 Touchpad` to specify a device as well. Fromo now on we'll use that to specify our device in scripts and commands, since I'm not sure how or when the `id`s are assigned, and I'd rather make sure we are reliably setting the properties on the touchpad, and not inadverdently messing with some other device.

Like the device id/name, the properties can also be referenced by numerical id (i.e. `293`), or the full property name string (i.e. `libinput Disable While Typing Enabled`). We'll use the string our in commands/scripts for readability. 

To enable two-finger and three-finger clicking for this trackpad:

```bash
xinput set-prop "DLL06E4:01 06CB:7A13 Touchpad" "libinput Click Method Enabled" 0 1
```

To enable tap-to-click:

```bash
xinput set-prop "DLL06E4:01 06CB:7A13 Touchpad" "libinput Tapping Enabled" 1
```

To enable natural scrolling:

```bash
xinput set-prop "DLL06E4:01 06CB:7A13 Touchpad" "libinput Natural Scrolling Enabled" 1
```

I found that my mouse was not moving as quickly across the screen as I wanted, so I changed the pointer speed, as well:

```bash
xinput set-prop "DLL06E4:01 06CB:7A13 Touchpad" "libinput Accel Speed" 1
```

# `libinput-gestures` configuration

The configuration file for `libinput-gestures` resides at `~/.config/libinput-gestures.conf`. Check out [my `libinput-gestures.conf`](https://github.com/Spirotot/dotFiles/blob/arch/.config/libinput-gestures.conf) for i3-specific configuration, and/or check out [the sample `libinput-gestures.conf`](https://github.com/bulletmark/libinput-gestures/blob/master/libinput-gestures.conf).

# i3 configuration

Simply add the following to your i3 config:

`exec --no-startup-id libinput-gestures`

That will start libinput-gestures when i3 starts.


# References

* [Libinput ArchWiki](https://wiki.archlinux.org/index.php/Libinput)
* [libinput-gestures](https://github.com/bulletmark/libinput-gestures)
* [More libinput info, good details about Disable While Typing](https://wayland.freedesktop.org/libinput/doc/latest/palm_detection.html)


