Re: [PATCH 4/4] speakup: Add documentation on changing the speakup messages language

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



One more, similar to talkwith, handles also fenrir.

Didier
#!/bin/sh
# Didier Spaier <didier~at~slint.fr> 2019
# I wrote this script from scratch and put it in the public domain.
# I assume that the packages espeakup and speechd-up are installed.
# If fenrir is installed, it can also be used.
if [ ! $(id -u) -eq 0 ]; then
	echo "Please run this script as root."
	exit
fi
speakup="  a hard synthesizer (type its name, like \"apollo\" or \"acntsa\")"
if [ -x /usr/bin/espeakup ]; then
	espeakup="  espeakup (Console screen reader connecting espeak-ng and speakup)\n"
	n1="espeakup"
fi
if [ -x /usr/bin/speechd-up ]; then
	speechd_up="  speechd-up (Console screen reader connecting Speech Dispatcher and speakup)"
	n2="speechd-up"
fi
if [ -x /usr/bin/fenrir ]; then
	fenrir="  fenrir (Modular, flexible and fast console screen reader)\n"
	n3="fenrir"
fi
readers="$espeakup$fenrir$speechd_up"
hardlist="$(zgrep SPEAKUP_S /proc/config.gz|grep [ym]|grep -v DUMMY| \
sed 's/CONFIG_SPEAKUP_SYNTH_//;s/..$//'|tr '[:upper:]' '[:lower:]')"
usage() {
  echo "Usage: $0 <screen reader> or <hard synthesizer> or none"
  echo "Choose a console screen reader to talk with among:" 
  echo -e "$readers"
  echo "or use one of the supported hard synthesizers:"
  echo "  "$hardlist
  echo "or type  \"$0 none\" to mute all screen readers." 
  exit
}
to_lower() {
echo "$1"|tr '[:upper:]' '[:lower:]'
}
ARGUMENT=$(to_lower $1)
if [ $# -ne 1 ]; then usage; fi
if [ ! "$ARGUMENT" = "$n1" ] && \
   [ ! "$ARGUMENT" = "$n2" ] && \
   [ ! "$ARGUMENT" = "$n3" ] && \
   ! echo $hardlist| grep -qw $ARGUMENT && \
   [ ! "$ARGUMENT" = "none" ]; then
	echo "$1 is not a valid argument of this command."
	usage
	exit
fi
# We first check which console screen reader is already running, if any.
if [ ! "$(ps -C fenrir --noheaders|wc -l)" = "0" ]; then
	FENRIR=y
fi
if [ -f /sys/accessibility/speakup/synth ]; then
	SPKSYNTH=$(cat /sys/accessibility/speakup/synth)
	if [ "$SPKSYNTH" = "soft" ]; then 
		if [ ! "$(ps -C speechd-up --noheaders|wc -l)" = "0" ]; then
			SPEECHDUP="y"
		fi
		if [ ! "$(ps -C espeakup --noheaders|wc -l)" = "0" ]; then
			ESPEAKUP="y"
		fi
	else
	HARD=$SPKSYNTH
	fi
fi
# If a hard synth is in use store its name as we need to override it to
# use a soft synth instead if wished, but we need to restore it if the
# user does not want a permanent change.
if [ -f /etc/speakup.conf ]; then
	. /etc/speakup.conf
fi
case $ARGUMENT in
	espeakup)
		if [ ! -x /usr/bin/espeakup ]; then 
			echo "espeakup is not installed."
			exit
		fi
		if [ "$ESPEAKUP" = "y" ]; then
			echo "$1 is already started."
			exit
		fi
		if [ "$FENRIR" = "y" ]; then
			[ -f /etc/rc.d/rc.fenrir ] && sh /etc/rc.d/rc.fenrir stop
		fi
		if [ "$SPEECHDUP" = "y" ]; then
			sh /etc/rc.d/rc.speechd-up stop
		fi
		echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
		echo "hard=none" >> /etc/speakup.conf
		sh /etc/rc.d/rc.espeakup start
		sleep 1
		printf "Should espeakup be also started at next boot? [Y/n] "
		read ANSWER
		if [ ! "$(to_lower $ANSWER)" = "n" ]; then
			chmod 755 /etc/rc.d/rc.espeakup
			chmod 644 /etc/rc.d/rc.speechd-up
			[ -f /etc/rc.d/rc.fenrir ] && chmod 644 /etc/rc.d/rc.fenrir
			echo "Done."
		elif [ ! "$hard" = "" ]; then
			echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
			echo hard=$hard >> /etc/speakup.conf
		fi
	;;
	speechd-up)
		if [ ! -x /usr/bin/speechd-up ]; then
			echo "speechd-up is not installed."
			exit
		fi
		if [ "$SPEECHDUP" = "y" ]; then
			echo "speechd-up is already started."
			exit
		fi
		if [ "$FENRIR" = "y" ]; then
			sh /etc/rc.d/rc.fenrir stop
		fi
		if [ "$ESPEAKUP" = "y" ]; then
			sh /etc/rc.d/rc.espeakup stop
		fi
		echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
		echo "hard=none" >> /etc/speakup.conf
		sh /etc/rc.d/rc.speechd-up start
		sleep 1
		printf "Should speechd-up be also started at next boot? [Y/n] "
		read ANSWER
		if [ ! "$(to_lower $ANSWER)" = "n" ]; then
			chmod 644 /etc/rc.d/rc.espeakup
			[ -f /etc/rc.d/rc.fenrir ] && chmod 644 /etc/rc.d/rc.fenrir
			chmod 755 /etc/rc.d/rc.speechd-up
			echo "Done."
		elif [ ! "$hard" = "" ]; then
			echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
			echo hard=$hard >> /etc/speakup.conf
		fi
	;;
	fenrir)
		if [ ! -x /usr/bin/fenrir ]; then
			echo "fenrir is not installed."
			exit
		fi
		if [ "$FENRIR" = "y" ]; then
			echo "fenrir is already started."
			exit
		fi
		if [ "$SPEECHDUP" = "y" ]; then
			sh /etc/rc.d/rc.speechd-up stop
		fi
		if [ "$ESPEAKUP" = "y" ]; then
			sh /etc/rc.d/rc.espeakup stop
		fi
		if [ ! "$SPKSYNTH" = "" ]; then
			echo none > /sys/accessibility/speakup/synth
		fi
		echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
		echo "hard=none" >> /etc/speakup.conf
		sh /etc/rc.d/rc.fenrir start
		sleep 1
		clear
		printf "Should fenrir be also started at boot time? [Y/n] "
		read ANSWER
		if [ ! "$(to_lower $ANSWER)" = "n" ]; then 
			chmod 644 /etc/rc.d/rc.espeakup
			chmod 644 /etc/rc.d/rc.speechd-up
			chmod 755 /etc/rc.d/rc.fenrir
			echo "Done."
		elif [ ! "$hard" = "" ]; then
			echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
			echo hard=$hard >> /etc/speakup.conf
		fi
	;;
	none)
		if [ "$FENRIR" = "y" ]; then
			sh /etc/rc.d/rc.fenrir stop
		fi
		if [ "$ESPEAKUP" = "y" ]; then
			sh /etc/rc.d/rc.espeakup stop
		fi
		if [ "$SPEECHDUP" = "y" ]; then
			sh /etc/rc.d/rc.speechd-up stop
		fi
		if [ ! "$SPKSYNTH" = "" ]; then
			echo none > /sys/accessibility/speakup/synth
		fi
		printf "Do you also want a mute console at next boot? [Y/n] "
		read ANSWER
		if [ ! "$(to_lower $ANSWER)" = "n" ]; then
			chmod 644 /etc/rc.d/rc.espeakup
			chmod 644 /etc/rc.d/rc.speechd-up
			[ -f /etc/rc.d/rc.fenrir ] && chmod 644 /etc/rc.d/rc.fenrir
			echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
			echo "hard=none" >> /etc/speakup.conf
			echo "OK"
		fi
	;;
	*)
		if [ "$FENRIR" = "y" ]; then
			sh /etc/rc.d/rc.fenrir stop
		fi
		if [ "$ESPEAKUP" = "y" ]; then
			sh /etc/rc.d/rc.espeakup stop
		fi
		if [ "$SPEECHDUP" = "y" ]; then
			sh /etc/rc.d/rc.speechd-up stop
		fi
		modprobe speakup_$ARGUMENT 2>/dev/null
		echo $ARGUMENT  > /sys/accessibility/speakup/synth
		if [ $? != 0 ]; then
			echo "Unable to switch to the $ARGUMENT synthesizer."
			echo "Something should be wrong."
			exit 1
		fi
		printf "Should $ARGUMENT be also used at next boot? [Y/n] "
		read ANSWER
		if [ ! "$(to_lower $ANSWER)" = "n" ]; then
			chmod 644 /etc/rc.d/rc.speechd-up
			[ -f /etc/rc.d/rc.fenrir ] && chmod 644 /etc/rc.d/rc.fenrir
			chmod 755 /etc/rc.d/rc.espeakup
			echo "# File written by speak-with. Do not edit." > /etc/speakup.conf
			echo "hard=$ARGUMENT" >> /etc/speakup.conf
			echo "Done."
		fi
esac
_______________________________________________
Speakup mailing list
Speakup@xxxxxxxxxxxxxxxxx
http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup

[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]

  Powered by Linux