#!/bin/sh
#  This script enable the orca screen reader for the user who runs it.
export TEXTDOMAIN=slint-scripts
if [ "$(id -u)" = "0" ]; then
    gettext "Start a graphical environment as root with speech is not advisable."; echo
    gettext "Please run this script as regular user."; echo
    exit
fi
if [ -f ~/.profile ]; then
	(cd ~ || exit 1
	sed  "
	/SAL_USE_VCLPLUGIN/d
	/GNOME_ACCESSIBILITY/d
	/GTK_MODULES/d
	/QT_ACCESSIBILITY/d
	/QT_LINUX_ACCESSIBILITY_ALWAYS_ON/d
	/ACCESSIBILITY_ENABLED/d
	/startx_output/d" .profile > .dummyprofile
	mv .dummyprofile .profile
	)
fi
	cat <<-EOF >>~/.profile
	export SAL_USE_VCLPLUGIN="gtk"
	export GTK_MODULES="gail:atk-bridge" # for GTK2
	export GNOME_ACCESSIBILITY=1
	export QT_ACCESSIBILITY=1 # for QT4
	export QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1 # for QT5
	export ACCESSIBILITY_ENABLED=1 # for Chrome/Chromium
	EOF
if [ -f ~/.config/autostart/startorca.desktop ]; then
    (cd ~/.config/autostart/ || exit 1
    sed -i "s/Hidden.*/Hidden=false/" startorca.desktop
    )
    gsettings set org.mate.interface accessibility true 2>/dev/null
    gettext "Orca has been enabled for you."; echo
else
    gettext "File ~/.config/autostart/startorca.desktop not found."; echo
fi

# /startx_output/d to be removed in Slint 15
