#!/bin/bash
# Program to load modules for accessibility, like speakup_soft
# Load DRBL setting and functions
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
. /etc/drbl/drbl-ocs.conf
. $DRBL_SCRIPT_PATH/sbin/ocs-functions
. /etc/ocs/ocs-live.conf

#
ocs_modprobe_timeout_def=150  # Unit: 0.1 sec, time to wait for modprobe to be finished

[ -z "$ocs_modprobe_timeout" ] && ocs_modprobe_timeout=$ocs_modprobe_timeout_def

# The following is borrowed from Debian Stretch installer.
SYNTH=$(sed < /proc/cmdline -n -e 's/.*speakup\.synth=\([^ ]*\).*/\1/p')
if [ -n "$SYNTH" ]; then
	# Get and set the locale in /etc/default/espeak
	espeak_voice="$(LC_ALL=C printenv LANG | awk -F"_" '{print $1}')"
	if [ -n "$espeak_voice" ]; then
	  perl -pi -e "s/^VOICE=.*/VOICE=$espeak_voice/g" /etc/default/espeakup
	fi
	sync;sync;sync
	echo "Running: modprobe speakup_$SYNTH"
	modprobe speakup_$SYNTH
	#debconf-set debian-installer/framebuffer false
	#register-module -i speakup_$SYNTH
	echo "Running: systemctl start espeakup"
	systemctl start espeakup
fi
