-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·306 lines (282 loc) · 8.14 KB
/
configure
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
#!/bin/bash
set -uo pipefail
CONFIG_FILE="config"
function generate_makefile {
m4 -P Makefile.m4 > Makefile
make Makefile
}
if ! command -v dialog; then
echo '"dialog" not found, please install before continuing"
exit 1
fi
if ! command -v m4; then
echo 'm4" not found, please install before continuing"
exit 1
fi
if ! command -v make; then
echo 'make" not found, please install before continuing"
exit 1
fi
if ! command -v awk; then
echo 'awk" not found, please install before continuing"
exit 1
fi
if [ -f "${CONFIG_FILE}" ]; then
dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Overwrite settings?" \
--defaultno \
--yesno "A config file already exists, do you want to make that file over again? If you press No, the Makefile will be processed again based on the current config file." 0 0
if [ "$?" -eq 1 ]; then
generate_makefile
exit 0
fi
source ${CONFIG_FILE}
fi
: "${DT_DOTFILES_DIR:=$(pwd)}"
: "${DT_HOME_DIRECTORY:=${HOME:-}}"
: "${DT_SHELL:=${SHELL:-}}"
: "${DT_EDITOR:=${EDITOR:-}}"
: "${DT_SYSID:=1}"
: "${DT_DISTRO:=}"
: "${DT_OS:=linux}"
: "${DT_DOTFILES_TYPE:=local}"
: "${DT_GIT_USER:=${DT_GIT_AUTHOR_NAME:-}}"
: "${DT_GIT_EMAIL:=${DT_GIT_AUTHOR_EMAIL:-}}"
: "${DT_TOOLS:=yes}"
: "${DT_OTHER_SYMLINKS:=yes}"
: "${DT_NEOVIM:=yes}"
: "${DT_ZSH:=no}"
: "${DT_TLP:=no}"
: "${DT_AUTORANDR:=no}"
: "${DT_GREETD_TUIGREET:=no}"
: "${DT_POWERLINE_P10K:=no}"
: "${DT_SWAY:=no}"
: "${DT_QTILE:=no}"
: "${DT_BASH:=yes}"
: "${DT_HOMEBIN:=no}"
: "${DT_GOTIFY_URL:=}"
: "${DT_GOTIFY_TOKEN:=}"
: "${DT_TMUX:=yes}"
: "${DT_MYCLI:=no}"
: "${DT_NEWSBOAT:=no}"
: "${DT_ALACRITTY:=yes}"
: "${DT_ROFI:=no}"
: "${DT_DEADD:=no}"
: "${DT_WAYBAR:=no}"
: "${DT_FOOT:=no}"
: "${DT_POWERLINE:=no}"
: "${DT_SXHKD:=no}"
: "${DT_BSPWM:=no}"
: "${DT_INPUTRC:=yes}"
: "${DT_VIM:=yes}"
radiolist_on() {
local value="$1"
if [[ "$value" == "$2" ]]; then
echo "on"
else
echo "off"
fi
}
checklist_on() {
local value="$1"
if [[ "$value" == "yes" ]]; then
echo "on"
else
echo "off"
fi
}
DT_HOME_DIRECTORY=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--inputbox "Home directory" \
0 0 "${DT_HOME_DIRECTORY}" \
3>&1 1>&2 2>&3 3>&-)
if [ "$?" -eq 1 ]; then exit 0; fi
DT_SHELL=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--inputbox "Default shell" \
0 0 "${DT_SHELL}" \
3>&1 1>&2 2>&3 3>&-)
if [ "$?" -eq 1 ]; then exit 0; fi
DT_EDITOR=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--inputbox "Default editor" \
0 0 "${DT_EDITOR}" \
3>&1 1>&2 2>&3 3>&-)
if [ "$?" -eq 1 ]; then exit 0; fi
DT_SYSID=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--inputbox "System id (magical number)" \
0 0 "${DT_SYSID}" \
3>&1 1>&2 2>&3 3>&-)
if [ "$?" -eq 1 ]; then exit 0; fi
SYSTEM_TYPE=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--radiolist "System type" \
0 0 0 \
0 "Local" $(radiolist_on "${DT_DOTFILES_TYPE}" "local") \
1 "Remote" $(radiolist_on "${DT_DOTFILES_TYPE}" "remote") \
3>&1 1>&2 2>&3 3>&-)
if [ "$?" -eq 1 ]; then exit 0; fi
case $SYSTEM_TYPE in
0) DT_DOTFILES_TYPE=local;;
1) DT_DOTFILES_TYPE=remote;;
esac
DISTRO=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--radiolist "Distro" \
0 0 0 \
0 "Debian" $(radiolist_on "${DT_DISTRO}" "debian") \
1 "Fedora" $(radiolist_on "${DT_DISTRO}" "fedora") \
3>&1 1>&2 2>&3 3>&-)
if [ "$?" -eq 1 ]; then exit 0; fi
case $DISTRO in
0) DT_DISTRO=debian;;
1) DT_DISTRO=fedora;;
esac
GIT_VALUES=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--form "Git settings" \
0 50 0 \
"Username:" 1 1 "${GIT_AUTHOR_NAME:-}" 1 10 255 0 \
"Email:" 2 1 "${GIT_AUTHOR_EMAIL:-}" 2 10 255 0 \
3>&1 1>&2 2>&3 3>&-)
GIT_VALUES=($GIT_VALUES)
if [ "$?" -eq 1 ]; then exit 0; fi
DT_GIT_USER=${GIT_VALUES[0]}
DT_GIT_EMAIL=${GIT_VALUES[1]}
FEATURES="$(dialog --stdout \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--checklist "Change dotfile features (be aware that turning them off is not really possible):" 0 0 0 \
1 "General tools (highligt, mediainfo, git, ripgrep...)" $(checklist_on "${DT_TOOLS}") \
2 "Other dotfile symlinks (Not for specific features below)" $(checklist_on "${DT_OTHER_SYMLINKS}") \
3 "neovim" $(checklist_on "${DT_NEOVIM}") \
4 "ZSH and Oh-My-Zsh" $(checklist_on "${DT_ZSH}") \
5 "tlp" $(checklist_on "${DT_TLP}") \
6 "autorandr" $(checklist_on "${DT_AUTORANDR}") \
7 "greetd and tuigreet" $(checklist_on "${DT_GREETD_TUIGREET}") \
8 "Powerline and P10K" $(checklist_on "${DT_POWERLINE_P10K}") \
9 "Sway" $(checklist_on "${DT_SWAY}") \
10 "QTile" $(checklist_on "${DT_QTILE}") \
11 "Bash" $(checklist_on "${DT_BASH}") \
12 "home folder bin dir" $(checklist_on "${DT_HOMEBIN}") \
13 "tmux" $(checklist_on "${DT_NEOVIM}") \
15 "MyCLI" $(checklist_on "${DT_MYCLI}") \
16 "Newsboat" $(checklist_on "${DT_NEWSBOAT}") \
17 "Alacritty" $(checklist_on "${DT_ALACRITTY}") \
18 "Rofi" $(checklist_on "${DT_ROFI}") \
19 "Deadd" $(checklist_on "${DT_DEADD}") \
20 "Waybar (needed for sway)" $(checklist_on "${DT_WAYBAR}") \
21 "Foot" $(checklist_on "${DT_FOOT}") \
22 "Powerline" $(checklist_on "${DT_POWERLINE}") \
23 "Sxhkd" $(checklist_on "${DT_SXHKD}") \
24 "Bspwm" $(checklist_on "${DT_BSPWM}") \
25 "Inputrc (usefull for bash, less, read etc)" $(checklist_on "${DT_INPUTRC}") \
26 "Vim" $(checklist_on "${DT_VIM}"))"
if [ "$?" -eq 1 ]; then exit 0; fi
DT_TOOLS=no
DT_OTHER_SYMLINKS=no
DT_NEOVIM=no
DT_ZSH=no
DT_TLP=no
DT_AUTORANDR=no
DT_GREETD_TUIGREET=no
DT_POWERLINE_P10K=no
DT_SWAY=no
DT_QTILE=no
DT_BASH=no
DT_HOMEBIN=no
DT_TMUX=no
DT_MYCLI=no
DT_NEWSBOAT=no
DT_ALACRITTY=no
DT_ROFI=no
DT_DEADD=no
DT_WAYBAR=no
DT_FOOT=no
DT_POWERLINE=no
DT_SXHKD=no
DT_BSPWM=no
DT_INPUTRC=no
DT_VIM=no
for choice in ${FEATURES}; do
case $choice in
1) DT_TOOLS=yes;;
2) DT_OTHER_SYMLINKS=yes;;
3) DT_NEOVIM=yes;;
4) DT_ZSH=yes;;
5) DT_TLP=yes;;
6) DT_AUTORANDR=yes;;
7) DT_GREETD_TUIGREET=yes;;
8) DT_POWERLINE_P10K=yes;;
9) DT_SWAY=yes;;
10) DT_QTILE=yes;;
11) DT_BASH=yes;;
12) DT_HOMEBIN=yes;;
13) DT_TMUX=yes;;
15) DT_MYCLI=yes;;
16) DT_NEWSBOAT=yes;;
17) DT_ALACRITTY=yes;;
18) DT_ROFI=yes;;
19) DT_DEADD=yes;;
20) DT_WAYBAR=yes;;
21) DT_FOOT=yes;;
22) DT_POWERLINE=yes;;
23) DT_SXHKD=yes;;
24) DT_BSPWM=yes;;
25) DT_INPUTRC=yes;;
26) DT_VIM=yes;;
esac
done
if [ "${DT_NEWSBOAT}" = "yes" ]; then
NEWSBOAT_VALUES=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--form "Newsboat settings" \
0 50 0 \
"Url:" 1 1 "${DT_NEWSBOAT_SOURCE:-}" 1 10 255 0 \
"Username:" 2 1 "${DT_NEWSBOAT_USER:-}" 2 10 255 0 \
3>&1 1>&2 2>&3 3>&-)
if [ "$?" -eq 1 ]; then exit 0; fi
NEWSBOAT_VALUES=($NEWSBOAT_VALUES)
DT_NEWSBOAT_SOURCE=${NEWSBOAT_VALUES[0]}
DT_NEWSBOAT_USER=${NEWSBOAT_VALUES[1]}
fi
if [ "${DT_HOMEBIN}" = "yes" ]; then
GOTIFY_VALUES=$(dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Configure" \
--form "Gotify (push) settings" \
0 50 0 \
"Url:" 1 1 "${DT_GOTIFY_URL:-}" 1 10 255 0 \
"Push token:" 2 1 "${DT_GOTIFY_TOKEN:-}" 2 10 255 0 \
3>&1 1>&2 2>&3 3>&-)
if [ "$?" -eq 1 ]; then exit 0; fi
GOTIFY_VALUES=($GOTIFY_VALUES)
DT_GOTIFY_URL=${GOTIFY_VALUES[0]}
DT_GOTIFY_TOKEN=${GOTIFY_VALUES[1]}
fi
# write config to file
printf "" > "${CONFIG_FILE}"
set | grep '^DT_' | awk -F '=' '{print $1"="$2""}' >> "${CONFIG_FILE}"
# generate makefile
generate_makefile