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
|
#!/bin/bash
set -o pipefail
M4_DEF_FILE="system.m4"
if [ -f "${M4_DEF_FILE}" ]; then
dialog \
--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
m4 -P Makefile.m4 > Makefile
exit 0
fi
fi
HOME_DIRECTORY=$(dialog \
--backtitle "Dotfile configuration" \
--title "Configure" \
--inputbox "Home directory" \
0 0 "${HOME}" \
3>&1 1>&2 2>&3 3>&-)
DEFAULT_SHELL=$(dialog \
--backtitle "Dotfile configuration" \
--title "Configure" \
--inputbox "Default shell" \
0 0 "/usr/bin/zsh" \
3>&1 1>&2 2>&3 3>&-)
DEFAULT_EDITOR=$(dialog \
--backtitle "Dotfile configuration" \
--title "Configure" \
--inputbox "Default editor" \
0 0 "nvim" \
3>&1 1>&2 2>&3 3>&-)
SYSID=$(dialog \
--backtitle "Dotfile configuration" \
--title "Configure" \
--inputbox "System id (magical number)" \
0 0 "1" \
3>&1 1>&2 2>&3 3>&-)
SYSTEM_TYPE=$(dialog \
--backtitle "Dotfile configuration" \
--title "Configure" \
--radiolist "System type" \
0 0 0 \
0 "Local" on \
1 "Remote" off \
3>&1 1>&2 2>&3 3>&-)
DISTRO=$(dialog \
--backtitle "Dotfile configuration" \
--title "Configure" \
--radiolist "Distro" \
0 0 0 \
0 "Debian" on \
1 "Fedora" off \
3>&1 1>&2 2>&3 3>&-)
GIT_VALUES=$(dialog \
--backtitle "Dotfile configuration" \
--title "Configure" \
--form "Git settings" \
0 50 0 \
"Username:" 1 1 "$GIT_USER" 1 10 255 0 \
"Email:" 2 1 "$GIT_EMAIL" 2 10 255 0 \
3>&1 1>&2 2>&3 3>&-)
GIT_VALUES=($GIT_VALUES)
FEATURES="$(dialog --stdout \
--backtitle "Dotfile configuration" \
--title "Configure" \
--checklist "Change dotfile features:" 0 0 10 \
1 "General tools (highligt, mediainfo, git, ripgrep...)" on \
2 "Other dotfile symlinks (Not for specific features below)" on \
3 "neovim" on \
4 "ZSH and Oh-My-Zsh" off \
5 "tlp" off \
6 "autorandr" off \
7 "greetd and tuigreet" off \
8 "Powerline and P10K" off \
9 "Sway" off \
10 "QTile" off)"
# Write all to file
echo "m4_define(\`DOTFILES_DIR', \`$(pwd)')m4_dnl" > ${M4_DEF_FILE}
echo "m4_define(\`HOME_DIRECTORY', \`${HOME_DIRECTORY}')m4_dnl" >> ${M4_DEF_FILE}
echo "m4_define(\`DEFAULT_SHELL', \`${DEFAULT_SHELL}')m4_dnl" >> ${M4_DEF_FILE}
echo "m4_define(\`DEFAULT_EDITOR', \`${DEFAULT_EDITOR}')m4_dnl" >> ${M4_DEF_FILE}
echo "m4_define(\`SYSID', \`${SYSID}')m4_dnl" >> ${M4_DEF_FILE}
case $SYSTEM_TYPE in
0)
echo "m4_define(\`DOTFILES_TYPE', \`local')m4_dnl" >> ${M4_DEF_FILE}
;;
1)
echo "m4_define(\`DOTFILES_TYPE', \`remote')m4_dnl" >> ${M4_DEF_FILE}
;;
esac
case $DISTRO in
0)
echo "m4_define(\`DISTRO', \`debian')m4_dnl" >> ${M4_DEF_FILE}
;;
1)
echo "m4_define(\`DISTRO', \`fedora')m4_dnl" >> ${M4_DEF_FILE}
;;
esac
echo "m4_define(\`GIT_USER', \`${GIT_VALUES[0]}')m4_dnl" >> ${M4_DEF_FILE}
echo "m4_define(\`GIT_EMAIL', \`${GIT_VALUES[1]}')m4_dnl" >> ${M4_DEF_FILE}
for choice in ${FEATURES}; do
case $choice in
1)
echo "m4_define(\`INSTALL_TOOLS', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
2)
echo "m4_define(\`INSTALL_OTHER_SYMLINKS', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
3)
echo "m4_define(\`INSTALL_NEOVIM', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
4)
echo "m4_define(\`INSTALL_OH_MY_ZSH', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
5)
echo "m4_define(\`INSTALL_TLP', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
6)
echo "m4_define(\`INSTALL_AUTORANDR', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
7)
echo "m4_define(\`INSTALL_GREETD_TUIGREET', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
8)
echo "m4_define(\`INSTALL_POWERLINE_P10K', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
9)
echo "m4_define(\`INSTALL_SWAY', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
10)
echo "m4_define(\`INSTALL_QTILE', \`1')m4_dnl" >> ${M4_DEF_FILE}
;;
esac
done
m4 -P Makefile.m4 > Makefile
|