blob: 9e137572aa280f6c4c4bd4fbcab4031984e3a2a2 (
plain) (
blame)
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
|
#!/bin/bash
set -uo pipefail
CONFIG_FILE="config"
function generate_makefile {
m4 -P Makefile.m4 > Makefile
make Makefile
}
if [ -f "${CONFIG_FILE}" ]; then
dialog \
--keep-tite \
--backtitle "Dotfile configuration" \
--title "Overwrite settings?" \
--defaultno \
--yesno "A system.m4 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 system.m4 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_TMUX:=yes}"
: "${DT_HELIX:=no}"
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}") \
14 "Helix" $(checklist_on "${DT_HELIX}"))"
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_HELIX=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;;
14) DT_HELIX=yes;;
esac
done
# write config to file
printf "" > "${CONFIG_FILE}"
set | grep '^DT_' | awk -F '=' '{print $1"="$2""}' >> "${CONFIG_FILE}"
# generate makefile
generate_makefile
|