#! /bin/sh

set -e

if [ -n "$(lsmod | grep ^speakup_)" ]; then

	. /usr/share/debconf/confmodule

	# Gnome 3
	mkdir -p /target/usr/share/glib-2.0/schemas
	cat >/target/usr/share/glib-2.0/schemas/15_speakup.gschema.override <<END
# Setup by debian-installer (via finish-install.d/07speakup) since
# speech synthesis was enabled during initial installation

[org.gnome.desktop.a11y.applications]
screen-reader-enabled=true

[org.gnome.desktop.sound]
event-sounds=true
END
	in-target dpkg-trigger --no-await /usr/share/glib-2.0/schemas || true
	in-target dpkg --triggers-only -a || true

	# XFCE

	db_get passwd/username
	USERNAME="$RET"
	if [ -n "$USERNAME" ]
	then
		# XFCE
		mkdir -p /target/home/$USERNAME/.config/xfce4/xfconf/xfce-perchannel-xml
		cat > /target/home/$USERNAME/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml <<END
<?xml version="1.0" encoding="UTF-8"?>

<channel name="xfce4-session" version="1.0">
  <property name="general" type="empty">
    <property name="StartAssistiveTechnologies" type="bool" value="true"/>
  </property>
</channel>
END
	fi
fi

exit 0
