#!/bin/sh
#
# Enable a dolphin popup when inserting a removable media on a LTSP thin
# client.
#
# Activate this using
# ln -s /usr/share/debian-edu-config/ltspfs-mounter-kde /etc/ltspfs/mounter.d/

set -e

case "$1" in
    enable)
	ln -s /usr/share/debian-edu-config/ltspfs-mounter-kde \
	    /etc/ltspfs/mounter.d/
	;;
    add)
	# Floppy drives show up when the user log in, even without a floppy
	# in them.
	floppy=$(echo "$2" | grep floppy);

	# Gnome handle LTSPFS popups internally
	gnome=$(echo "$XDG_DATA_DIRS" | grep /usr/share/gnome)

	if [ -z "$floppy" ] && [ -z "$gnome" ] \
	    && type dolphin > /dev/null 2>&1 ; then
            dolphin $2 > /dev/null 2>&1 < /dev/null || true
	fi
	;;
    remove)
	;;
esac
