3
# casper-a11y-enable - Sets accessibility profile settings for the live session
6
# This script is called by several other scripts, as well as ubiquity itself to
7
# set up accessibility profile settings for use in the live environment and on
10
# Copyright (C) 2011, Canonical Ltd.
13
# - Luke Yelavich <luke.yelavich@canonical.com>
15
# This script is free software; you can redistribute it and/or modify it under
16
# the terms of the GNU General Public License as published by the Free
17
# Software Foundation; either version 2 of the License, or at your option)
20
# This program is distributed in the hope that it will be useful,
21
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
# GNU General Public License for more details.
25
# You should have received a copy of the GNU General Public License along
26
# with this application; if not, write to the Free Software Foundation, Inc., 51
27
# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
##################################################################################
32
### PROFILE SETTINGS METHODS BEGIN HERE ###
33
# The methods that are used to set profile data have been placed as close to the
34
# top of this file as possible, so they are easy to locate, and will hopefully
35
# save time when making smaller changes.
37
# Common settings for low vision profiles. Any change you make here will affect
38
# all low vision profiles, for both the user session and login manager.
41
gset set com.canonical.indicator.datetime show-calendar false
42
gset set org.gnome.desktop.interface toolkit-accessibility true
43
gct -s -t bool /desktop/gnome/interface/accessibility true
44
gct -s -t bool /apps/gksu/disable-grab true
45
gset set org.gnome.yelp show-cursor true
48
# Common settings for motor profiles. Any change you make here will affect
49
# all motor profiles, for both the user session and login manager.
52
gset set org.gnome.desktop.a11y.keyboard enable true
53
gct -s -t bool /apps/gksu/disable-grab true
54
gset set org.gnome.desktop.a11y.keyboard stickykeys-enable true
55
gset set org.gnome.desktop.a11y.keyboard stickykeys-two-key-off false
58
# Settings for the high-contrast profile.
61
gset set org.gnome.desktop.interface icon-theme HighContrast
62
gset set org.gnome.desktop.interface monospace-font-name "monospace 18"
63
gset set org.gnome.desktop.interface font-name "sans 18"
64
gset set org.gnome.desktop.background picture-uri ""
65
gset set org.gnome.desktop.background picture-options none
66
gset set org.gnome.desktop.background primary-color \#666666
67
gset set org.gnome.desktop.background secondary-color \#7F7F7F
68
gset set org.gnome.desktop.background color-shading-type solid
69
gset set org.gnome.desktop.interface cursor-size 48
70
gset set org.gnome.desktop.interface cursor-theme whiteglass
71
kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/
72
if [ -d $CHROOT_DIR/usr/share/xubuntu-default-settings/accessibility ]; then
73
cp -a $CHROOT_DIR/usr/share/xubuntu-default-settings/accessibility/* $CHROOT_DIR/etc/xdg/
76
if [ -n "$SET_LOGIN" ]; then
77
gset_lightdm set com.canonical.unity-greeter high-contrast true
84
gset set org.gnome.desktop.a11y.applications screen-magnifier-enabled true
85
set_orca_config magnifier
88
kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/,/usr/share/kubuntu-default-settings/kde-profile/moderate-visual-impairment/
93
gset set org.gnome.desktop.a11y.applications screen-reader-enabled true
94
gset set org.gnome.Empathy.conversation theme classic
95
set_orca_config speech
97
if [ -n "$SET_LOGIN" ]; then
98
gset_lightdm set com.canonical.unity-greeter screen-reader true
104
gset set org.gnome.desktop.a11y.applications screen-reader-enabled true
105
gset set org.gnome.Empathy.conversation theme classic
106
set_orca_config braille
108
if [ -n "$SET_LOGIN" ]; then
109
gset_lightdm set com.canonical.unity-greeter screen-reader true
113
set_keyboard_modifiers()
115
gset set org.gnome.desktop.a11y.keyboard mousekeys-enable true
116
gset set org.gnome.desktop.a11y.keyboard stickykeys-modifier-beep true
117
gset set org.gnome.settings-daemon.peripherals.keyboard repeat true
118
gset set org.gnome.settings-daemon.peripherals.keyboard delay 700
119
gset set org.gnome.settings-daemon.peripherals.keyboard repeat-interval 10
120
kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/minor-motor-difficulties/
121
if [ -e $CHROOT_DIR/etc/xdg/xfce4/mcs_settings/keyboard.xml ]; then
122
sed -i 's/0/1/' $CHROOT_DIR/etc/xdg/xfce4/mcs_settings/keyboard.xml
126
set_onscreen_keyboard()
128
gset set org.gnome.desktop.interface toolkit-accessibility true
129
gset set org.gnome.desktop.a11y.keyboard stickykeys-modifier-beep false
130
gset set org.gnome.desktop.a11y.applications screen-keyboard-enabled true
132
if [ -n "$SET_LOGIN" ]; then
133
gset_lightdm set com.canonical.unity-greeter onscreen-keyboard true
136
kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/minor-motor-difficulties/,/usr/share/kubuntu-default-settings/kde-profile/motor-difficulties-pointing-devices/
137
if [ -e $CHROOT_DIR/etc/xdg/xfce4/mcs_settings/keyboard.xml ]; then
138
sed -i '/Sticky/ s/0/1/' $CHROOT_DIR/etc/xdg/xfce4/mcs_settings/keyboard.xml
141
### PROFILE SETTINGS METHODS END HERE ###
146
Usage: $0 [-chroot=<root>] [-user=<username>] [-l|-login]
147
[-i|-initramfs] [-d|-debug] <profilename>
149
-h, -help Display this help.
150
-chroot=<root> Chroot into <root> to apply profile settings, requires a
151
username to be specified, see below.
152
-user=<username> The user where a profile is to be applied, requires the
153
script to be run as root. If no username is given, it
154
is assumed that you wish to apply profile settings for
156
-l, -login Apply some of the selected profile settings to the
157
login manager. Currently this is hard-coded to lightdm.
158
This requires root privileges.
159
-i, -initramfs Indicate that the script is being called from the
160
initramfs. Allows the script to assume some values
161
that can not otherwise be easily determined in an
162
initramfs environment. Requires that a chroot dir and
163
user name are specified. See above.
164
-script Create a script to be run at system boot that will
165
apply all settings for the specified user and for
166
login. This script will then remove itself. This is
167
needed to work around gsettings not working in a chroot
168
environment with no dconf service running.
169
-d|-debug Enable debugging output.
170
<profilename> The name of the profile you wish to apply, see below.
172
The profiles currently available are as follows:
173
high-contrast For users with lesser visual impairments who only need a high
174
contrast theme, mouse cursor and icons.
175
magnifier For users with moderate visual impairments who require a screen
177
blindness Users who are partially or completely blind who require a screen
179
braille Users who are partially or completely blind who require a screen
180
reader and wish to use a Braille display.
182
Users who have minor motor impairments who require slight
183
changes to the way their keyboard behaves.
185
Users with motor impairments who require the use of an
192
if [ -n "$GLIBBIN_VERSION" ]; then
193
if [ -n "$STARTUP_SCRIPT" ]; then
194
echo "gsettings " "$@" >> $CHROOT_DIR/usr/bin/a11y-profile-settings
196
$DO_CHROOT $DO_SUDO gsettings "$@"
203
if [ -n "$GLIBBIN_VERSION" ]; then
204
if [ -n "$STARTUP_SCRIPT" ]; then
205
echo "gsettings " "$@" >> $CHROOT_DIR/usr/bin/a11y-profile-settings-lightdm
207
$DO_CHROOT sudo -u lightdm gsettings "$@"
212
# Soon to be deprecated
215
if [ -n "$GCONF_VERSION" ]; then
216
if [ -n "$STARTUP_SCRIPT" ]; then
217
echo "gconftool-2 " "$@" >> $CHROOT_DIR/usr/bin/a11y-profile-settings
219
$DO_CHROOT $DO_SUDO gconftool-2 "$@"
224
kderc_addtoprefixes()
226
if [ -e $CHROOT_DIR/etc/kde4rc ]; then
227
sed -i "s|\\(prefixes=/usr/share/kubuntu-default-settings/kde-profile/default/\\)|\\1,$1|" $CHROOT_DIR/etc/kde4rc
231
# Unfortunately this bloats this script somewhat, but orca doesn't seem to want
232
# to deal with individual settings/a small config fragment.
233
# Arguments: $1 = speech/magnifier/braille (which
234
# accessibility feature to turn on)
237
# Yes, we could use $HOME, but enquiring about $HOME is not easy when
238
# Outside the target environment, particularly when running from the
239
# initramfs, and this script is not everything for everybody anyway.
240
if [ -n "$ORCA_VERSION" ] && ! [ -f "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf" ]; then
241
mkdir -p "$CHROOT_DIR/home/$USER_NAME/.local/share/orca"
243
cat <<EOF > "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf"
245
"pronunciations": {},
253
"pronunciations": {},
258
"speakCellHeaders": true,
260
"brailleContractionTable": "",
261
"magPointerFollowsFocus": false,
262
"magTextTrackingMode": 2,
263
"magZoomerBorderSize": 1,
264
"brailleAlignmentStyle": 0,
265
"enableEchoByWord": false,
266
"enableMagZoomerColorInversion": false,
268
"magSmoothingMode": 0,
269
"magZoomerLeft": 840,
270
"showMainWindow": true,
272
"brailleSelectorIndicator": 192,
273
"presentDateFormat": "%x",
274
"magContrastLevel": 0,
275
"magMouseTrackingMode": 0,
276
"speakCellSpan": true,
277
"progressBarUpdateInterval": 10,
278
"speakCellCoordinates": true,
279
"enablePauseBreaks": true,
280
"brailleEOLIndicator": " $l",
281
"verbalizePunctuationStyle": 1,
282
"progressBarVerbosity": 1,
283
"enableSpeech": false,
284
"enableBraille": false,
285
"chatAnnounceBuddyTyping": false,
286
"speakMultiCaseStringsAsWords": false,
287
"enableBrailleGrouping": false,
288
"readTableCellRow": true,
289
"speechServerFactory": "speechdispatcherfactory",
290
"textAttributesBrailleIndicator": 0,
291
"enableMagCursorExplicitSize": false,
292
"messageVerbosityLevel": 1,
293
"enableMagLiveUpdating": true,
294
"enableSpeechIndentation": false,
295
"enableKeyEcho": true,
296
"magHideCursor": false,
297
"magZoomerBorderColor": "#000000",
298
"magPointerFollowsZoomer": true,
299
"mouseDwellDelay": 0,
300
"magBrightnessLevelRed": 0,
301
"enableMagnifier": false,
302
"magZoomFactor": 4.0,
307
"enableMagZoomerBorder": false,
308
"flashVerbosityLevel": 1,
309
"enableFlashMessages": true,
310
"speechServerInfo": null,
311
"presentToolTips": false,
312
"flashIsPersistent": false,
313
"skipBlankCells": false,
315
"largeObjectTextLength": 75,
316
"enableEchoBySentence": false,
317
"magContrastLevelBlue": 0,
318
"magContrastLevelRed": 0,
319
"enableContractedBraille": false,
320
"orcaModifierKeys": [
324
"enableMagCursor": true,
325
"speechRequiredStateString": "required",
326
"quitOrcaNoConfirmation": false,
327
"brailleRequiredStateString": "required",
328
"magCursorColor": "#000000",
329
"enablePositionSpeaking": false,
331
"onlySpeakDisplayedText": false,
332
"enableProgressBarUpdates": true,
333
"wrappedStructuralNavigation": true,
334
"chatRoomHistories": false,
335
"brailleVerbosityLevel": 1,
336
"enableFunctionKeys": true,
337
"enableModifierKeys": true,
338
"magCrossHairColor": "#000000",
339
"enableTutorialMessages": false,
340
"enableActionKeys": true,
341
"speakBlankLines": true,
342
"magColorFilteringMode": 0,
343
"magZoomerRight": 1680,
345
"magTargetDisplay": "",
346
"disableBrailleEOL": false,
348
"magSourceDisplay": "",
349
"enableDiacriticalKeys": false,
350
"enableMnemonicSpeaking": false,
351
"enabledBrailledTextAttributes": "size:; family-name:; weight:400; indent:0; underline:none; strikethrough:false; justification:left; style:normal; text-spelling:none;",
352
"speechVerbosityLevel": 1,
353
"enableMagCrossHair": true,
354
"enableBrailleMonitor": false,
369
"magContrastLevelGreen": 0,
370
"brailleFlashTime": 5000,
371
"magCrossHairSize": 16,
372
"enableMouseReview": false,
373
"enableNavigationKeys": false,
374
"magBrightnessLevelGreen": 0,
375
"chatSpeakRoomName": false,
380
"enableLockingKeys": true,
385
"brailleRolenameStyle": 1,
386
"brailleLinkIndicator": 192,
387
"enableEchoByCharacter": false,
388
"magBrightnessLevelBlue": 0,
389
"enableBrailleContext": true,
390
"magControlTrackingMode": 2,
391
"magZoomerBottom": 1050,
392
"enablePrintableKeys": true,
393
"enabledSpokenTextAttributes": "size:; family-name:; weight:400; indent:0; underline:none; strikethrough:false; justification:left; style:normal; paragraph-style:; text-spelling:none;",
394
"chatMessageVerbosity": 0,
395
"presentTimeFormat": "%X",
396
"magBrightnessLevel": 0,
397
"presentRequiredState": false,
398
"enableMagCrossHairClip": false
405
sed -i -e 's/\"enableMagnifier\": false/\"enableMagnifier\": true/' "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf"
408
sed -i -e 's/\"enableSpeech\": false/\"enableSpeech\": true/' "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf"
411
sed -i -e 's/\"enableBraille\": false/\"enableBraille\": true/' "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf"
417
if [ "$HOME" = "/root" ] || [ -n "$IN_INITRAMFS" ]; then
418
chmod 755 "$CHROOT_DIR/home/$USER_NAME/.local/share/orca"
419
$DO_CHROOT chown $USER_NAME.$USER_NAME -R "/home/$USER_NAME/.local"
426
cat <<EOF > /tmp/casper-a11y.conf
427
UBIQUITY_A11Y_PROFILE=$1
431
if [ "$#" = "0" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
436
while [ "$#" -gt 0 ];
440
CHROOT_DIR="${1#-chroot=}"
441
DO_CHROOT="chroot $CHROOT_DIR"
446
USER_NAME="${1#-user=}"
447
DO_SUDO="sudo -u $USER_NAME"
479
if [ -n "$IN_INITRAMFS" ] && [ -z "$CHROOT_DIR" ]; then
480
echo "Error: In initramfs, but no chroot directory specified."
483
elif [ -n "$IN_INITRAMFS" ] && [ -z "$USER_NAME" ]; then
484
echo "Error: In initramfs, but no username specified."
489
if [ -n "$SET_LOGIN" ] && [ "$HOME" != "/root" ] && [ -z "$IN_INITRAMFS" ]; then
490
echo "Error: Setting up accessibility for login requires root privileges."
496
if [ -n "$CHROOT_DIR" ] || [ -n "$USER_NAME" ]; then
497
if [ "$HOME" != "/root" ] && [ -z "$IN_INITRAMFS" ]; then
498
echo "Error: You are not running as root."
504
if [ -n "$CHROOT_DIR" ]; then
505
if [ ! -d "$CHROOT_DIR" ]; then
506
echo "Error: Target chroot directory does not exist, or you do not have permission to access it."
509
if [ -z "$IN_INITRAMFS" ] && ! type chroot >/dev/null 2>&1 ; then
510
echo "Error: Chroot command not available in running environment."
515
if [ -n "$STARTUP_SCRIPT" ]; then
516
if [ -z "$USER_NAME" ]; then
517
echo "Error: You have requested to create a startup script, but no user was specified."
520
if [ "$HOME" != "/root" ] && [ -z "$IN_INITRAMFS" ]; then
521
echo "Error: You have requested to create a startup script, but you do not have root"
525
if [ -z "$CHROOT_DIR" ]; then
526
echo "Error: You have requested to create a startup script, but you did not specify"
527
echo "a target directory to chroot to."
532
# If no username was entered on the command line, grab the name of the current
533
# user, so we can write files to their home directory.
534
if [ -z "$USER_NAME" ]; then
535
if [ -z "$USER" ]; then
536
USER_NAME="${HOME#/home/}"
542
# Check to see if a few necessary packages are present in the target
544
GCONF_VERSION=$($DO_CHROOT /usr/bin/dpkg-query -W --showformat='${Version}' gconf2 2>/dev/null) || GCONF_VERSION=""
545
GLIBBIN_VERSION=$($DO_CHROOT /usr/bin/dpkg-query -W --showformat='${Version}' libglib2.0-bin 2>/dev/null) || GLIBBIN_VERSION=""
546
ORCA_VERSION=$($DO_CHROOT /usr/bin/dpkg-query -W --showformat='${Version}' gnome-orca 2>/dev/null) || ORCA_VERSION=""
548
if [ -n "$STARTUP_SCRIPT" ]; then
549
cat <<EOF > $CHROOT_DIR/etc/init/a11y-profile-settings.conf
550
# a11y-profile-settings - A job to set up accessibility settings
552
description "Accessibility profile settings"
554
start on runlevel [2345]
559
sudo -u $USER_NAME /usr/bin/dbus-launch --exit-with-session /usr/bin/a11y-profile-settings
560
sudo -u lightdm /usr/bin/dbus-launch --exit-with-session /usr/bin/a11y-profile-settings-lightdm
561
rm /usr/bin/a11y-profile-settings /usr/bin/a11y-profile-settings-lightdm
562
rm /etc/init/a11y-profile-settings.conf
565
cat <<EOF > $CHROOT_DIR/usr/bin/a11y-profile-settings
568
# Created by the casper accessibility profile settings script on
571
# This script deletes itself once run.
574
cat <<EOF > $CHROOT_DIR/usr/bin/a11y-profile-settings-lightdm
577
# Created by the casper accessibility profile settings script on
580
# This script deletes itself once run.
585
case $PROFILE_NAME in
589
create_conf $PROFILE_NAME
594
create_conf $PROFILE_NAME
599
create_conf screen-reader
604
create_conf $PROFILE_NAME
608
set_keyboard_modifiers
609
create_conf $PROFILE_NAME
613
set_onscreen_keyboard
614
create_conf $PROFILE_NAME
618
if [ -n "$STARTUP_SCRIPT" ]; then
619
chmod 755 $CHROOT_DIR/usr/bin/a11y-profile-settings*