-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbn-install.sh
executable file
·309 lines (271 loc) · 4.99 KB
/
dbn-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#!/bin/bash
# Create the working directory, if it doesn't exist, then cd into it
if [ ! -d ~/.DvorakByNizo ]
then
mkdir ~/.DvorakByNizo
fi
cd ~/.DvorakByNizo
##################
# Check for args #
##################
if [ $# -eq 0 ]
then
clear
#################################
# Choose the installer language #
#################################
cat << language
[1] Deutsch
[2] English
[Q] Quit
language
# Get user input, then set an array with all the strings
while true; do
read -p 'Selection [1/2/Q]:' lang
case $lang in
1)
text=("Ungültige Eingabe"
"Auswahl"
"Dieses Skript installiert das \"Dvorak by
Nizo (German)\" Layout, wodurch es Dvorak
Type II überschreibt.
[1] Mit FN Layer
[2] Ohne FN Layer
[Q] Stop"
"Benutzen sie ein DE/einen WM, der/die
key.type benötigt?
GNOME - beides geht
KDE - ?
Xfce - No
LXDE - ?
MATE - ?
Cinnamon - ?
i3 - Yes"
"Es existiert bereits ein Backup.
Soll dieses überschrieben werden?
(Dieses Skript erstellt kein
Backup eines Backups)"
"Nein"
"Ja"
"Backup erstellen/überschreiben (automatisch
ausgewählt, falls keines bisher
existiert)"
"Fortfahren?"
"Erstelle Backup..."
"Downloaden benötigter Dateien..."
"Zusammenstellen der Datei..."
"Das Layout ist installiert. Bitte ausloggen und wieder einloggen, danach das Layout auf \"Deutsch (Dvorak)\" stellen.")
break
;;
2)
text=("Invalid input"
"Selection"
"This script will install the \"Dvorak by
Nizo (German)\" layout by overriding
Dvorak Type II
[1] With FN Layer
[2] Without FN Layer
[Q] Quit"
"Do you use a DE/WM that needs key.type?
GNOME - choose either
KDE - ?
Xfce - No
LXDE - ?
MATE - ?
Cinnamon - ?
i3 - Yes"
"There's already a backup.
Override it? (This script can't
backup a backup)"
"No"
"Yes"
"Create/override backup (chosen automatically
if there is none)"
"Is this correct?"
"Creating backup..."
"Downloading needed files..."
"Building file..."
"All done. Please log out and back in, then set the layout to German (Dvorak).")
break
;;
[qQ]*)
echo "exiting..."
exit 1
;;
*)
echo 'Invalid input' >&2
echo
esac
done
clear
###########
# Start #
# 1 - yes #
# 0 - no #
###########
#############
# Ask stuff #
#############
# Ask for FN layer
echo "${text[2]}"
echo
while true; do
read -p "${text[1]} [1/2/Q]: " fn
case $fn in
1)
break
;;
2)
fn=0
break
;;
[qQ])
echo "exiting..."
exit 1
;;
*)
echo ${text[0]} >&2
esac
done
clear
# Ask for key.type
echo "${text[3]}"
echo
while true; do
read -p "${text[1]} [y/n]: " yn
case $yn in
[yY])
keytype=1
break
;;
[nN])
keytype=0
break
;;
*)
echo ${text[0]} >&2
esac
done
# Check for backup
backup=1
if [ -f ~/.DvorakByNizo/de.bak ]
then
echo
while true; do
read -p "${text[4]} [y/n]: " yn
case $yn in
[yY])
break
;;
[nN])
backup=0
break
;;
*)
echo ${text[0]} >&2
esac
done
fi
clear
#Ask for confirmation
echo "FN: ${text[$((5 + $fn))]}"
echo "key.type: ${text[$((5 + $keytype))]}"
echo "${text[7]}: ${text[$((5 + $backup))]}"
echo
while true; do
read -p "${text[8]} [y/n]: " conf
case $conf in
[yY])
break
;;
[nN])
echo "exiting..."
exit 1
;;
*)
echo ${text[0]} >&2
esac
done
else
for arg in $@
do
case $arg in
fn)
fn=1
;;
nofn)
fn=0
;;
type)
keytype=1
;;
notype)
keytype=0
;;
bak)
backup=1
;;
nobak)
backup=0
;;
*)
echo "Usage:"
echo
echo "./dbn-install.sh"
echo or
echo "./dbn-install.sh [no]fn [no]type [no]bak"
echo
echo "no: prefix to set the following options to no. Otherwise, they'll be \"yes\"."
echo "fn: FN Layer"
echo "type: key.type"
echo "bak: create backup"
echo
exit 0
esac
done
fi
############
# Do stuff #
############
# Backup
echo
if [ $backup -eq 1 ]
then
echo "${text[9]}"
cp /usr/share/X11/xkb/symbols/de de.bak
fi
# Collecting files, deleting old ones
echo "${text[10]}"
echo "1/3..."
rm before &> /dev/null
wget https://raw.githubusercontent.com/theNizo/DvorakByNizo-German/master/Linux/before &> /dev/null
echo "2/3..."
rm after &> /dev/null
wget https://raw.githubusercontent.com/theNizo/DvorakByNizo-German/master/Linux/after &> /dev/null
echo "3/3..."
# Download either FN or non-FN
if [ $fn -eq 1 ]
then
wget https://raw.githubusercontent.com/theNizo/DvorakByNizo-German/master/Linux/dbn-FN &> /dev/null
mv dbn-FN dbn-standalone
else
wget https://raw.githubusercontent.com/theNizo/DvorakByNizo-German/master/Linux/dbn &> /dev/null
mv dbn dbn-standalone
fi
# Correcting key.type
if [ $keytype -eq 1 ]
then
sed -i 's/\/\/key.type/key.type/' dbn-standalone
fi
# Building file
echo "${text[11]}"
cat before dbn-standalone after > dbn-build
# Install file (this has to be seperate)
sudo cp dbn-build /usr/share/X11/xkb/symbols/de
#sudo cat before dbn-standalone after > /usr/share/X11/xkb/symbols/de
echo
echo "==========="
echo "${text[12]}"
echo "==========="
echo
exit 0