~elementary-os/ubuntu-package-imports/casper-trusty

« back to all changes in this revision

Viewing changes to bin/casper-a11y-enable

  • Committer: RabbitBot
  • Date: 2014-03-17 06:25:38 UTC
  • Revision ID: rabbitbot@elementaryos.org-20140317062538-37t3mejnxd39um5y
Initial import, version 1.338

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# casper-a11y-enable - Sets accessibility profile settings for the live session
 
4
#                      or installed system.
 
5
#
 
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
 
8
# an installed system.
 
9
#
 
10
# Copyright (C) 2011, Canonical Ltd.
 
11
#
 
12
# Author:
 
13
# - Luke Yelavich <luke.yelavich@canonical.com>
 
14
#
 
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)
 
18
# any later version.
 
19
#
 
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.
 
24
#
 
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
##################################################################################
 
29
 
 
30
set -e
 
31
 
 
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.
 
36
 
 
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.
 
39
set_common_lowvis()
 
40
{
 
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
 
46
}
 
47
 
 
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.
 
50
set_common_motor()
 
51
{
 
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
 
56
}
 
57
 
 
58
# Settings for the high-contrast profile.
 
59
set_high_contrast()
 
60
{
 
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/
 
74
        fi
 
75
 
 
76
        if [ -n "$SET_LOGIN" ]; then
 
77
                gset_lightdm set com.canonical.unity-greeter high-contrast true
 
78
        fi
 
79
}
 
80
 
 
81
set_magnifier()
 
82
{
 
83
        # Ubuntu
 
84
        gset set org.gnome.desktop.a11y.applications screen-magnifier-enabled true
 
85
        set_orca_config magnifier
 
86
 
 
87
        # Kubuntu
 
88
        kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/,/usr/share/kubuntu-default-settings/kde-profile/moderate-visual-impairment/
 
89
}
 
90
 
 
91
set_blindness()
 
92
{
 
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
 
96
 
 
97
        if [ -n "$SET_LOGIN" ]; then
 
98
                gset_lightdm set com.canonical.unity-greeter screen-reader true
 
99
        fi
 
100
}
 
101
 
 
102
set_braille()
 
103
{
 
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
 
107
 
 
108
        if [ -n "$SET_LOGIN" ]; then
 
109
                gset_lightdm set com.canonical.unity-greeter screen-reader true
 
110
        fi
 
111
}
 
112
 
 
113
set_keyboard_modifiers()
 
114
{
 
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
 
123
        fi
 
124
}
 
125
 
 
126
set_onscreen_keyboard()
 
127
{
 
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
 
131
 
 
132
        if [ -n "$SET_LOGIN" ]; then
 
133
                gset_lightdm set com.canonical.unity-greeter onscreen-keyboard true
 
134
        fi
 
135
 
 
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
 
139
        fi
 
140
}
 
141
### PROFILE SETTINGS METHODS END HERE ###
 
142
 
 
143
help()
 
144
{
 
145
        cat <<EOF
 
146
Usage: $0               [-chroot=<root>] [-user=<username>] [-l|-login]
 
147
                        [-i|-initramfs] [-d|-debug] <profilename>
 
148
 
 
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
 
155
                        the current user.
 
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.
 
171
 
 
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
 
176
                magnifier.
 
177
blindness       Users who are partially or completely blind who require a screen
 
178
                reader.
 
179
braille         Users who are partially or completely blind who require a screen
 
180
                reader and wish to use a Braille display.
 
181
keyboard-modifiers
 
182
                Users who have minor motor impairments who require slight
 
183
                changes to the way their keyboard behaves.
 
184
onscreen-keyboard
 
185
                Users with motor impairments who require the use of an
 
186
                on-screen keyboard.
 
187
EOF
 
188
}
 
189
 
 
190
gset()
 
191
{
 
192
        if [ -n "$GLIBBIN_VERSION" ]; then
 
193
                if [ -n "$STARTUP_SCRIPT" ]; then
 
194
                        echo "gsettings " "$@" >> $CHROOT_DIR/usr/bin/a11y-profile-settings
 
195
                else
 
196
                        $DO_CHROOT $DO_SUDO gsettings "$@"
 
197
                fi
 
198
        fi
 
199
}
 
200
 
 
201
gset_lightdm()
 
202
{
 
203
        if [ -n "$GLIBBIN_VERSION" ]; then
 
204
                if [ -n "$STARTUP_SCRIPT" ]; then
 
205
                        echo "gsettings " "$@" >> $CHROOT_DIR/usr/bin/a11y-profile-settings-lightdm
 
206
                else
 
207
                        $DO_CHROOT sudo -u lightdm gsettings "$@"
 
208
                fi
 
209
        fi
 
210
}
 
211
 
 
212
# Soon to be deprecated
 
213
gct()
 
214
{
 
215
        if [ -n "$GCONF_VERSION" ]; then
 
216
                if [ -n "$STARTUP_SCRIPT" ]; then
 
217
                        echo "gconftool-2 " "$@" >> $CHROOT_DIR/usr/bin/a11y-profile-settings
 
218
                else
 
219
                        $DO_CHROOT $DO_SUDO gconftool-2 "$@"
 
220
                fi
 
221
        fi
 
222
}
 
223
 
 
224
kderc_addtoprefixes()
 
225
{
 
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
 
228
        fi
 
229
}
 
230
 
 
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)
 
235
set_orca_config()
 
236
{
 
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"
 
242
 
 
243
                cat <<EOF > "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf"
 
244
{
 
245
    "pronunciations": {}, 
 
246
    "keybindings": {}, 
 
247
    "profiles": {
 
248
        "default": {
 
249
            "profile": [
 
250
                "Default", 
 
251
                "default"
 
252
            ], 
 
253
            "pronunciations": {}, 
 
254
            "keybindings": {}
 
255
        }
 
256
    }, 
 
257
    "general": {
 
258
        "speakCellHeaders": true, 
 
259
        "magEdgeMargin": 0, 
 
260
        "brailleContractionTable": "", 
 
261
        "magPointerFollowsFocus": false, 
 
262
        "magTextTrackingMode": 2, 
 
263
        "magZoomerBorderSize": 1, 
 
264
        "brailleAlignmentStyle": 0, 
 
265
        "enableEchoByWord": false, 
 
266
        "enableMagZoomerColorInversion": false, 
 
267
        "magCursorSize": 32, 
 
268
        "magSmoothingMode": 0, 
 
269
        "magZoomerLeft": 840, 
 
270
        "showMainWindow": true, 
 
271
        "sayAllStyle": 1, 
 
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, 
 
303
        "activeProfile": [
 
304
            "Default", 
 
305
            "default"
 
306
        ], 
 
307
        "enableMagZoomerBorder": false, 
 
308
        "flashVerbosityLevel": 1, 
 
309
        "enableFlashMessages": true, 
 
310
        "speechServerInfo": null, 
 
311
        "presentToolTips": false, 
 
312
        "flashIsPersistent": false, 
 
313
        "skipBlankCells": false, 
 
314
        "firstStart": false, 
 
315
        "largeObjectTextLength": 75, 
 
316
        "enableEchoBySentence": false, 
 
317
        "magContrastLevelBlue": 0, 
 
318
        "magContrastLevelRed": 0, 
 
319
        "enableContractedBraille": false, 
 
320
        "orcaModifierKeys": [
 
321
            "Insert", 
 
322
            "KP_Insert"
 
323
        ], 
 
324
        "enableMagCursor": true, 
 
325
        "speechRequiredStateString": "required", 
 
326
        "quitOrcaNoConfirmation": false, 
 
327
        "brailleRequiredStateString": "required", 
 
328
        "magCursorColor": "#000000", 
 
329
        "enablePositionSpeaking": false, 
 
330
        "magZoomerType": 0, 
 
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, 
 
344
        "keyboardLayout": 1, 
 
345
        "magTargetDisplay": "", 
 
346
        "disableBrailleEOL": false, 
 
347
        "magZoomerTop": 0, 
 
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, 
 
355
        "voices": {
 
356
            "default": {
 
357
                "established": false
 
358
            }, 
 
359
            "uppercase": {
 
360
                "average-pitch": 5.6
 
361
            }, 
 
362
            "system": {
 
363
                "established": false
 
364
            }, 
 
365
            "hyperlink": {
 
366
                "established": false
 
367
            }
 
368
        }, 
 
369
        "magContrastLevelGreen": 0, 
 
370
        "brailleFlashTime": 5000, 
 
371
        "magCrossHairSize": 16, 
 
372
        "enableMouseReview": false, 
 
373
        "enableNavigationKeys": false, 
 
374
        "magBrightnessLevelGreen": 0, 
 
375
        "chatSpeakRoomName": false, 
 
376
        "startingProfile": [
 
377
            "Default", 
 
378
            "default"
 
379
        ], 
 
380
        "enableLockingKeys": true, 
 
381
        "profile": [
 
382
            "Default", 
 
383
            "default"
 
384
        ], 
 
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
 
399
    }
 
400
}
 
401
EOF
 
402
 
 
403
                case "$1" in
 
404
                        magnifier)
 
405
                                sed -i -e 's/\"enableMagnifier\": false/\"enableMagnifier\": true/' "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf"
 
406
                        ;;
 
407
                        speech)
 
408
                                sed -i -e 's/\"enableSpeech\": false/\"enableSpeech\": true/' "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf"
 
409
                        ;;
 
410
                        braille)
 
411
                                sed -i -e 's/\"enableBraille\": false/\"enableBraille\": true/' "$CHROOT_DIR/home/$USER_NAME/.local/share/orca/user-settings.conf"
 
412
                        ;;
 
413
                        *)
 
414
                        ;;
 
415
                esac
 
416
 
 
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"
 
420
                fi
 
421
        fi
 
422
}
 
423
 
 
424
create_conf()
 
425
{
 
426
        cat <<EOF > /tmp/casper-a11y.conf
 
427
UBIQUITY_A11Y_PROFILE=$1
 
428
EOF
 
429
}
 
430
 
 
431
if [ "$#" = "0" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
 
432
        help
 
433
        exit 1
 
434
fi
 
435
 
 
436
while [ "$#" -gt 0 ];
 
437
do
 
438
        case "$1" in
 
439
                -chroot=*)
 
440
                        CHROOT_DIR="${1#-chroot=}"
 
441
                        DO_CHROOT="chroot $CHROOT_DIR"
 
442
                        shift
 
443
                        continue
 
444
                ;;
 
445
                -user=*)
 
446
                        USER_NAME="${1#-user=}"
 
447
                        DO_SUDO="sudo -u $USER_NAME"
 
448
                        shift
 
449
                        continue
 
450
                ;;
 
451
                -l|-login)
 
452
                        SET_LOGIN=1
 
453
                        shift
 
454
                        continue
 
455
                ;;
 
456
                -i|-initramfs)
 
457
                        IN_INITRAMFS=1
 
458
                        shift
 
459
                        continue
 
460
                ;;
 
461
                -d|-debug)
 
462
                        set -x
 
463
                        shift
 
464
                        continue
 
465
                ;;
 
466
                -script)
 
467
                        STARTUP_SCRIPT=1
 
468
                        shift
 
469
                        continue
 
470
                ;;
 
471
                *)
 
472
                        PROFILE_NAME="$1"
 
473
                        shift
 
474
                        continue
 
475
                ;;
 
476
        esac
 
477
done
 
478
 
 
479
if [ -n "$IN_INITRAMFS" ] && [ -z "$CHROOT_DIR" ]; then
 
480
        echo "Error: In initramfs, but no chroot directory specified."
 
481
        help
 
482
        exit 1
 
483
elif [ -n "$IN_INITRAMFS" ] && [ -z "$USER_NAME" ]; then
 
484
        echo "Error: In initramfs, but no username specified."
 
485
        help
 
486
        exit 1
 
487
fi
 
488
 
 
489
if [ -n "$SET_LOGIN" ] && [ "$HOME" != "/root" ] && [ -z "$IN_INITRAMFS" ]; then
 
490
        echo "Error: Setting up accessibility for login requires root privileges."
 
491
        help
 
492
        exit 1
 
493
fi
 
494
 
 
495
 
 
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."
 
499
                help
 
500
                exit 1
 
501
        fi
 
502
fi
 
503
 
 
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."
 
507
                exit 1
 
508
        fi
 
509
        if [ -z "$IN_INITRAMFS" ] && ! type chroot >/dev/null 2>&1 ; then
 
510
                echo "Error: Chroot command not available in running environment."
 
511
                exit 1
 
512
        fi
 
513
fi
 
514
 
 
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."
 
518
                exit 1
 
519
        fi
 
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"
 
522
                echo "privileges."
 
523
                exit 1
 
524
        fi
 
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."
 
528
                exit 1
 
529
        fi
 
530
fi
 
531
 
 
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/}"
 
537
        else
 
538
                USER_NAME="$USER"
 
539
        fi
 
540
fi
 
541
 
 
542
# Check to see if a few necessary packages are present in the target
 
543
# environment.
 
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=""
 
547
 
 
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
 
551
 
 
552
description     "Accessibility profile settings"
 
553
 
 
554
start on runlevel [2345]
 
555
 
 
556
umask 022
 
557
 
 
558
script
 
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
 
563
end script
 
564
EOF
 
565
        cat <<EOF > $CHROOT_DIR/usr/bin/a11y-profile-settings
 
566
#!/bin/sh
 
567
 
 
568
# Created by the casper accessibility profile settings script on
 
569
# $(date).
 
570
 
 
571
# This script deletes itself once run.
 
572
 
 
573
EOF
 
574
        cat <<EOF > $CHROOT_DIR/usr/bin/a11y-profile-settings-lightdm
 
575
#!/bin/sh
 
576
 
 
577
# Created by the casper accessibility profile settings script on
 
578
# $(date).
 
579
 
 
580
# This script deletes itself once run.
 
581
 
 
582
EOF
 
583
fi
 
584
 
 
585
case $PROFILE_NAME in
 
586
        high-contrast)
 
587
                set_common_lowvis
 
588
                set_high_contrast
 
589
                create_conf $PROFILE_NAME
 
590
        ;;
 
591
        magnifier)
 
592
                set_common_lowvis
 
593
                set_magnifier
 
594
                create_conf $PROFILE_NAME
 
595
        ;;
 
596
        blindness)
 
597
                set_common_lowvis
 
598
                set_blindness
 
599
                create_conf screen-reader
 
600
        ;;
 
601
        braille)
 
602
                set_common_lowvis
 
603
                set_braille
 
604
                create_conf $PROFILE_NAME
 
605
        ;;
 
606
        keyboard-modifiers)
 
607
                set_common_motor
 
608
                set_keyboard_modifiers
 
609
                create_conf $PROFILE_NAME
 
610
        ;;
 
611
        onscreen-keyboard)
 
612
                set_common_motor
 
613
                set_onscreen_keyboard
 
614
                create_conf $PROFILE_NAME
 
615
        ;;
 
616
esac
 
617
 
 
618
if [ -n "$STARTUP_SCRIPT" ]; then
 
619
        chmod 755 $CHROOT_DIR/usr/bin/a11y-profile-settings*
 
620
fi