Resync with Debian's 1.157.1-1
[live-initramfs-grml.git] / scripts / live-bottom / 30accessibility
1 #!/bin/sh
2
3 #set -e
4
5 # initramfs-tools header
6
7 PREREQ=""
8
9 prereqs()
10 {
11         echo "${PREREQ}"
12 }
13
14 case "${1}" in
15         prereqs)
16                 prereqs
17                 exit 0
18                 ;;
19 esac
20
21 # live-initramfs header
22
23 if [ -n "${NOACCESSIBILITY}" ]
24 then
25         exit 0
26 fi
27
28 . /scripts/live-functions
29
30 if [ -z "${USERNAME}" ]
31 then
32         echo "No default user for accessibility options."
33         exit 0
34 fi
35
36 log_begin_msg "Configuring accessibility options"
37
38 # live-initramfs script
39
40 gconf_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gconf2 2>/dev/null) || gconf_version=""
41
42 gct ()
43 {
44         if [ "${gconf_version}" ]
45         then
46                 chroot /root sudo -u "${USERNAME}" gconftool-2 "${@}"
47         fi
48 }
49
50 laptop_detect ()
51 {
52         if chroot /root /usr/sbin/laptop-detect
53         then
54                 echo "orca.settings.orcaModifierKeys = orca.settings.LAPTOP_MODIFIER_KEYS" >> /root/home/$USERNAME/.orca/user-settings.py
55                 echo "orca.settings.keyboardLayout = orca.settings.GENERAL_KEYBOARD_LAYOUT_LAPTOP" >> /root/home/$USERNAME/.orca/user-settings.py
56         fi
57 }
58
59 remove_applet ()
60 {
61         # Code to remove an applet from the default panel setup
62         # This is rather hacky, but I can't think of a one or two line regular
63         # expression to do this any more efficiently. Patches welcome. In
64         # addition, setting these via gconf also doesn't work for some reason.
65
66         local line_no prior_line next_line
67
68         line_no="$(grep -n "<string>$1</string>" /root/usr/share/gconf/defaults/05_panel-default-setup.entries | cut -f 1 -d :)"
69         prior_line="$((line_no-1))"
70         next_line="$((line_no+1))"
71
72         sed -i -n "${prior_line},${next_line}!p" /root/usr/share/gconf/defaults/05_panel-default-setup.entries
73
74         chroot /root update-gconf-defaults
75 }
76
77 case ${ACCESS} in
78         access=v1)
79                 # Lesser Visual Impairment
80                 gct -s -t string /desktop/gnome/interface/gtk_theme HighContrastLargePrint
81                 gct -s -t string /desktop/gnome/interface/icon_theme HighContrast
82                 gct -s -t string /desktop/gnome/interface/monospace_font_name "monospace 18"
83                 gct -s -t string /desktop/gnome/interface/font_name "sans 18"
84                 gct -s -t string /apps/metacity/general/theme Atlanta
85                 gct -s -t string /desktop/gnome/background/picture_filename ""
86                 gct -s -t string /desktop/gnome/background/picture_options none
87                 gct -s -t string /desktop/gnome/background/primary_color \#666666
88                 gct -s -t string /desktop/gnome/background/secondary_color \#7F7F7F
89                 gct -s -t string /desktop/gnome/background/color_shading_type solid
90                 gct -s -t int /desktop/gnome/peripherals/mouse/cursor_size 48
91                 gct -s -t string /desktop/gnome/peripherals/mouse/cursor_theme whiteglass
92                 ;;
93
94         access=v2)
95                 # Moderate Visual Impairment
96                 gct -s -t bool /desktop/gnome/interface/accessibility true
97                 gct -s -t bool /desktop/gnome/applications/at/visual/startup true
98                 gct -s -t string /desktop/gnome/applications/at/visual/exec orca
99                 gct -s -t bool /apps/gksu/disable-grab true
100                 gct -s -t string /desktop/gnome/applications/window_manager/default /usr/bin/metacity
101
102                 if [ -x /root/usr/bin/orca ]
103                 then
104                         mkdir -p /root/home/${USERNAME}/.orca
105                         echo "import orca.settings" >> /root/home/${USERNAME}/.orca/user-settings.py
106                         echo "orca.settings.enableSpeech = False" >> /root/home/${USERNAME}/.orca/user-settings.py
107                         echo "orca.settings.enableMagnifier = True" >> /root/home/${USERNAME}/.orca/user-settings.py
108                         laptop_detect
109                         chroot /root chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.orca
110                 fi
111                 ;;
112
113         access=v3)
114                 # Blindness
115                 # Disabled for now, until we know eSpeak works.
116                 #gct -s -t bool /desktop/gnome/sound/enable_esd false
117                 gct -s -t bool /desktop/gnome/interface/accessibility true
118                 gct -s -t bool /desktop/gnome/applications/at/visual/startup true
119                 gct -s -t string /desktop/gnome/applications/at/visual/exec orca
120                 gct -s -t bool /apps/gksu/disable-grab true
121                 gct -s -t string /desktop/gnome/applications/window_manager/default /usr/bin/metacity
122
123                 remove_applet fast_user_switch
124                 ;;
125
126         braille=ask)
127                 # Braille
128                 gct -s -t bool /desktop/gnome/interface/accessibility true
129                 gct -s -t bool /desktop/gnome/applications/at/visual/startup true
130                 gct -s -t string /desktop/gnome/applications/at/visual/exec orca
131                 gct -s -t bool /apps/gksu/disable-grab true
132                 gct -s -t string /desktop/gnome/applications/window_manager/default /usr/bin/metacity
133
134                 if [ -x /root/usr/bin/orca ]
135                 then
136                         mkdir -p /root/home/${USERNAME}/.orca
137                         echo "import orca.settings" >> /root/home/${USERNAME}/.orca/user-settings.py
138                         echo "orca.settings.enableSpeech = False" >> /root/home/${USERNAME}/.orca/user-settings.py
139                         echo "orca.settings.enableBraille = True" >> /root/home/${USERNAME}/.orca/user-settings.py
140                         laptop_detect
141                         chroot /root chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.orca
142                 fi
143
144                 remove_applet fast_user_switch
145                 ;;
146
147         access=m1)
148                 # Minor Motor Difficulties
149                 gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true
150                 gct -s -t bool /desktop/gnome/accessibility/keyboard/mousekeys_enable true
151                 gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true
152                 gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep true
153                 gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false
154                 gct -s -t bool /desktop/gnome/peripherals/keyboard/repeat true
155                 gct -s -t int /desktop/gnome/peripherals/keyboard/delay 700
156                 gct -s -t int /desktop/gnome/peripherals/keyboard/rate 10
157                 gct -s -t bool /apps/gksu/disable-grab true
158
159                 if [ -e /root/etc/xdg/xfce4/mcs_settings/keyboard.xml ]
160                 then
161                         sed -i 's/0/1/' /root/etc/xdg/xfce4/mcs_settings/keyboard.xml
162                 fi
163                 ;;
164
165         access=m2)
166                 # Motor Difficulties - pointing devices
167                 gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true
168                 gct -s -t bool /desktop/gnome/interface/accessibility true
169                 gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true
170                 gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep false
171                 gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false
172                 gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [onboard]
173
174                 if [ -e /root/etc/xdg/xfce4/mcs_settings/keyboard.xml ]
175                 then
176                         sed -i '/Sticky/ s/0/1/' /root/etc/xdg/xfce4/mcs_settings/keyboard.xml
177                 fi
178                 ;;
179 esac
180
181 log_end_msg