#!/bin/sh
pid=/var/run/brltty.pid
[ -r $pid ] && kill -0 `cat $pid` || exit 0

# Source debconf library.
. /usr/share/debconf/confmodule

if [ -r /var/run/brltty-generic ]; then
        # a USB device was detected that may just look like a braille device,
        # ask for confirmation
	db_input critical brltty-udeb/generic
	if ! db_go; then
		exit 10 # back to main menu
	fi
	db_get brltty-udeb/generic
	if [ "$RET" = false ]; then
		# User does not actually want accessibility
		echo no > /var/run/brltty-generic
		kill `cat $pid`
		rm $pid
		exit 0
	else
		# Yes, they want it
		echo > /var/run/brltty-generic
	fi
fi
[ -n "$(debconf-get tasksel/desktop)" ] || debconf-set-selections /usr/share/brltty-udeb/mate-preseed.cfg
exit 0
