HP DisplayLink docking station in Ubuntu

DisplayLink docking stations works really good in Ubuntu. A list of supported devices can be found here.

I had the possibility to try out with one from HP, and there was some additional steps except from installing the DisplayLink driver for Ubuntu that was necessary to get a good experience (at least for me).

Start by downloading the deb package for Ubuntu here. Extract and install:

cd ~/Downloads
unzip DisplayLink\ USB\ Graphics\ Software\ for\ Ubuntu\ 1.2.1.zip
sudo bash displaylink-driver-1.2.65.run

It is easiest to just reboot your computer after the installation is done. I usually don’t plugin the docking station until I get to lightdm login screen.

You might have to adjust the order of the monitors under System settings, Display you have more than one external monitor connected.

Every time the HP docking station is connected, it will mount a USB mass storage device, containing the Windows drivers. This is quite annoying, but it’s easy to fix by blacklisting it with a udev rule. I also wanted to blacklist the Ethernet interface, since it isn’t used (and also caused problems NetworkManager dropping the wireless connections sometimes).

For the version of the docking station I was using, the following two rules would take care of that:

sudo bash -c 'tee /etc/udev/rules.d/98-displaylink-ignore.rules <<EOF
# Disable displaylink (port replicator) ethernet device
SUBSYSTEM=="usb", DRIVER=="cdc_ncm", ATTRS{interface}=="HP USB Giga Ethernet", \
ATTR{authorized}="0"

# Disable displaylink (port replicator) usb disk
SUBSYSTEM=="usb", ATTRS{idProduct}=="1165", ATTRS{idVendor}=="048d", \
ATTRS{manufacturer}=="iTE Tech", ATTR{authorized}="0"
EOF'

As always, udevadm info -a -p and the corresponding sysfs class path for the device, is the way to find correct information for your particular device.

Reload the udev rules without restarting:

sudo udevadm control --reload-rules

Citrix Receiver – use all available external monitors

When working on a remote server over Citrix, it is sometimes useful not having ICAClient to span over all monitors in fullscreen mode. It is possible to tell wfica to only span certain monitors with the -span parameter.

Change /opt/Citrix/ICAClient/wfica.sh to:

#!/bin/bash
ICAROOT=/opt/Citrix/ICAClient
export ICAROOT
LD_LIBRARY_PATH=/opt/Citrix/ICAClient/lib
export LD_LIBRARY_PATH

array_join() {
    local IFS="$1"
    shift
    echo "$*"
}

param=""
number_of_monitors="$(xrandr --query | grep -c " connected ")"

if (( number_of_monitors > 1 )); then
    param="-span"
    monitors=()
    for monitor in $(seq 2 "${number_of_monitors}"); do
        monitors+=("${monitor}")
    done

    param="${param} $(array_join ',' "${monitors[@]}")"
fi

$ICAROOT/wfica ${param} -file $1

This will use all monitors, except for the first one in fullscreen mode (unless you only have one monitor of course).

To get this to work automagically, Firefox has to be told to open *.ica files with this script. Go to Edit, Preferences, Applications, type ica in the search, select Use other... as action and browse to /opt/Citrix/ICAClient/wfica.sh.

Disable iPhone USB devices when charging via computer

I usually charge my iPhone by connecting it to my Ubuntu laptop. It is quite annoying that it tries to mount it as a USB-storage and adds it as an ethernet interface.

To the rescue: udev blacklisting:

sudo tee /etc/udev/rules.d/90-disable-iphone.rules <<EOF
# Disable iPhone ethernet device
SUBSYSTEM=="usb", DRIVER=="usb", ATTR{idProduct}=="12a8", ATTR{idVendor}=="05ac", ATTR{authorized}="0"
EOF

ATTR{idVendor} and ATTR{idProduct} might differ between different iPhone models. Examine with udevadm info -a -p /sys/class/net/<ethernet interface> and find any information, as close to the top as possible, that can be used to blacklist the device.

Download a sites certificates with openssl

The following snippet can be used to download all the CA certificates from a site, into seperate .crt files. The file name will be the last CN part from the issued information.

openssl s_client -connect $SITE:443 -showcerts \
        </dev/null 2>/dev/null | \
	awk '/^ [0-9] s:/,/^[-]+END CERTIFICATE/' | \
	csplit -q -z -f cert - '/^ [0-9] s:/' '{*}'
for file in cert*; do \
	name="$(awk -F= '/^ [0-9] s:/ {gsub(/[^A-Za-z0-9.]/, "", $NF); print $NF".crt"}' "${file}")"; \
	awk '/^[-]+BEGIN CERTIFICATE/,/^[-]+END CERTIFICATE/' "${file}" > "${name}"; \
	rm "${file}"; \
done

Example, if running the above with SITE=blog.mgor.net:

↳ openssl s_client -connect $SITE:443 -showcerts         </dev/null 2>/dev/null | awk '/^ [0-9] s:/'
 0 s:/CN=blog.mgor.net
 1 s:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3

Two certificate files will be created:

↳ ls *.crt
blog.mgor.net.crt  LetsEncryptAuthorityX3.crt