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

Thunderbird and Office365 (mail + calendar)

Here’s how you setup Thunderbird to work with mail and calendar from Office365.

Install dependencies

sudo apt install thunderbird

Start Thunderbird, and go to Tools, Add-ons, Get Add-ons.

Search for Lightning and install the add-on.

Goto Ericssons github repository for exchange calendar and download the latest stable version. Go back to Tools, Add-ons, Get Add-ons, click on the gear icon next to the search and choose Install Add-on From File.... Navigate to where you saved the xpi plugin file.

Configure mail

Go to Edit, Account Settings, Account Actions and Add Mail Account. Enter your settings.
IMAP server: outlook.office365.com:993
SMTP server: outlook.office365.com:587

Configure calendar

Go to the Calendar (lightning) tab, right click in the left menu pane under Calendar, chose New Calendar... and select On The Network.

Format: Microsoft Exchange 2007/2010/2013
Name: <Name of the calendar>
E-Mail: <E-mail account created in previous step>
Exchange Type: Microsoft Office365

Click Check server and mailbox, it will ask you for your password.

Folder base: Calendar folder

Finish the wizard, and you’re all done!