#!/bin/bash
# Gsettings commands to enable desktop accessibility and the Orca screen reader
#
# gsettings
#
# Copyright 2018, F123 Consulting, <information@f123.org>
# Copyright 2018, Kyle, <kyle@free2.ml>
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; see the file COPYING.  If not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
#--code--

export TEXTDOMAIN=gsettings
export TEXTDOMAINDIR=../locale

. gettext.sh

set -e

# Load the common functions
. ./functions

# Die if not running with root privileges
if ! check_root ; then
	PROGNAME=$0
	echo $(eval_gettext "Script must be run as root, try: sudo \$PROGNAME") ; echo
	exit 1
fi

# die if this script is called with no argument.
if [ -z $1 ]; then
	echo No root specified
	exit 1
fi

# Die if called with more than one argument
if [ $2 ]; then
	echo Too many arguments
	exit 1
fi

newroot=$1

# turn on MATE accessibility
systemd-nspawn -a -q -D "${newroot}" sudo -u \#1000 /bin/bash -c "dbus-launch gsettings set org.mate.interface accessibility true"
#pkill -n dbus-daemon

# Make Orca start automatically
systemd-nspawn -a -q -D "${newroot}" sudo -u \#1000 /bin/bash -c "dbus-launch gsettings set org.gnome.desktop.a11y.applications screen-reader-enabled true"

#pkill -n dbus-daemon

# Disable screen locking by default
systemd-nspawn -a -q -D "$newroot" sudo -u \#1000 /bin/bash -c "dbus-launch gsettings set org.mate.screensaver lock-enabled false"
#pkill -n dbus-daemon
