Apple Magic Trackpad 2 on Ubuntu Linux

The is a guide to installing the Apple Magic TrackPad 2 on Ubuntu Linux. While this guide has been written for Ubuntu 20.04, it should be easy to follow these instructions with minor changes for Fedora.

Plug the TrackPad in to USB. The trackpad should just work via a cabled connection. 2 Finger scrolling will work, a 2-finger tap is right mouse button, and a 3-finger tap is the middle button (or paste).

Enabling Bluetooth

To connect the trackpad via bluetooth, unplug the USB cable and turn the trackpad off, wait a second or two then turn it back on. The trackpad will now appear in bluetooth settings and can be paired.

Enabling Gesures

Add your user to the ‘input’ group. After doing this you will need to completely restart your session – the easiest way to do this is to reboot. Logging in and out will not work.

$ sudo gpasswd -a $USER input

Now you will need to install libinput-gesture – the example below uses the latest from git

$ sudo apt-get install xdotool wmctrl git python3 libinput-tools build-essential
$ mkdir ~/src/
$ cd ~/src/
$ git clone
$ cd libinput-gestures
$ sudo make install
$ libinput-gestures-setup autostart
$ libinput-gestures-setup start

After this, a three finger swipe up and down will switch workscapes. Read /etc/libinput-gestures.conf to see other options that are available.


Unfortunately, when used over bluetooth, the sensitivity of the touch to click is far too sensitive. I found that text was constantly accidently selected. This issue does not occour when the decice is wired.

Libinput seems to show the same device details as below for both wired and bluetooth – so I’ve not figured out that cause of this yet.

Device:           Apple Inc. Magic Trackpad 2
Kernel:           /dev/input/event25
Group:            6
Seat:             seat0, default
Size:             162x115mm
Capabilities:     pointer gesture
Tap-to-click:     disabled
Tap-and-drag:     enabled
Tap drag lock:    disabled
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: disabled
Calibration:      n/a
Scroll methods:   *two-finger edge 
Click methods:    button-areas *clickfinger 
Disable-w-typing: n/a
Accel profiles:   none
Rotation:         n/a

Generating a SHA-1 HMAC in Python

When signing a message posted to an API, sometimes an SHA1 digest or hash is required. This example shows the signing of a payload, and insertion of an X-Hmac header – however you may need to modify this depending on the API you are using.

def make_digest(message, key):
    key     = bytes(key, 'UTF-8')
    message = bytes(message, 'UTF-8')

    digester =, message, hashlib.sha1)
    sig = digester.hexdigest()
    return sig

The below shows an example API call against the Genband API, this shows the JSON payload being signed.

from requests import Session
import hmac
import hashlib
import json

def make_digest(message, key):
    key     = bytes(key, 'UTF-8')
    message = bytes(message, 'UTF-8')

    digester =, message, hashlib.sha1)
    sig = digester.hexdigest()
    return sig

s = Session()

base_api_url = ""
json_payload = "{}"
hmac_key = 'key-goes-here'
digest = make_digest(json_payload, hmac_key)

headers = {
        'X-Group-ID'    : 'group-id',
        'X-User-ID'     : 'user-id',
        'X-User-Token'  : 'token-here',
        'X-Hmac'         : digest

url = base_api_url + "path/to/method"
ret = s.get(url, headers=headers, json={})

Below shows the generation in PHP


$key = 'your-secure-key-here';
$payload = '{}';

echo hash_hmac('sha1', $payload, $key);

How to download YouTube videos using Docker on Linux

I recently found a 2 hour YouTube video where I wanted to listen to the audio only.  On trying to install youtube-dl on my server, I was shocked to see the number of packages that it was trying to install.

I run Ubuntu, but this should work in any Linux distro.  Using a docker container saves polluting your server with a lot of dependencies you might not need.

If you don’t already have it, install docker:

# curl -fsSL -o
# sh ./

The following will download a video to the current working directory:

# docker run --rm  -v $PWD:/downloads wernight/youtube-dl "

This will extract just the audio and give you the output as an mp3:

# docker run --rm  -v $PWD:/downloads wernight/youtube-dl --extract-audio --audio-format mp3  ""

Expanding a Dell PERC H800 RAID array with additional MD1200 shelves

Here is a short guide to creating a RAID 10 array on a PERC 800.  In my case, additional drives were added via 2 new MD1200 which were chained onto the existing shelves.

Continue reading “Expanding a Dell PERC H800 RAID array with additional MD1200 shelves”

Forcing cURL to use DNS though SOCK5 proxy

I recently had to code a REST call to a service I could only access behind a SOCK5 proxy.  Unfortunately, the hostname of the service wasn’t publicly resolvable so the DNS had to be resolved on the other side of the proxy.  Whilst this is pobbible in cURL itself by using the CURLOPT_PROXYTYPE option and setting it to CURLPROXY_SOCKS5_HOSTNAME or by using the flag –socks5-hostname – the constant isn’t available within PHP.  This feature was requested in however hasn’t yet been implemented.  This can simply be worked around by setting the proxy type to 7.  The code below shows an example of doing this using the Httpful library, however if you were using curl natively you’d just use curl_setopt()


$r = HttpfulRequest::post($url)
->addOnCurlOption(CURLOPT_PROXY, 'localhost:8080')
->addOnCurlOption(CURLOPT_PROXYTYPE, 7)

How and why I cracked a password hash

This was originally 2 years ago with references to the product and vendor. Unfortunately I got threatening legal letters, and almost lost my job! I’ve now stripped out the vendors references and am putting it up simply because I think others will find my methodologies and write up interesting.

Continue reading “How and why I cracked a password hash”

Installing VMWare’s ESXi guest tools on Ubuntu 11.10

There seems to be a lot of confusion in the IRC channel about how to install the guest tools on linux – with a lot of people recommending that you install the tools via the tools installer and the script. I really don’t like to do things this way – as I believe things should be installed using the package manager, and creating .debs of the tools means you don’t need to install a compiler on all of your guests.

Continue reading “Installing VMWare’s ESXi guest tools on Ubuntu 11.10”

Creating a custom form field type in symfony 2

I am finally starting to dive into symfony 2 properly. Yes – it’s taken a while, work has taken me in different directions! I found myself needing to create a custom form field type pretty quickly, but couldn’t find much in the way of documentation to do so, so I thought I’ld throw it up here; partly to help others, but mostly to get feedback to make sure I’m not approaching this from the wrong angle.

Continue reading “Creating a custom form field type in symfony 2”