-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·437 lines (357 loc) · 9.34 KB
/
setup
File metadata and controls
executable file
·437 lines (357 loc) · 9.34 KB
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
#!/bin/bash
read -r -d '' HEADER <<-'EOF'
:::::::. :::::::.. .,:::::: :::. . :
;;;'';;';;;;``;;;; ;;;;'''' ;;`;; ;;,. ;;;
[[[__[[\.[[[,/[[[' [[cccc ,[[ '[[, [[[[, ,[[[[,
$$""""Y$$$$$$$$c $$"""" c$$$cc$$$c $$$$$$$$"$$$
_88o,,od8P888b "88bo,888oo,__ 888 888,888 Y88" 888o
""YUMMMP" MMMM "W" """"YUMMMYMM ""` MMM M' "MMM
Bash Rules Everything Around Me
-----------------------------------------------------
EOF
# Bream setup script
# `setup local` - runs setup from working dir, like in a branch
# `setup files` - skips setup and just copies files from working dir
# `setup -b [branch]` - download and install a certain branch
bin_dir=/usr/bin
config_dir="$HOME"/.config
cache_dir="$HOME"/.cache/bream
git_url=https://git.doordesk.net/adam/bream.git
git_branch="master"
if [ "$1" = -b ]; then
git_branch="$2"
fi
if [ "$1" = local ]; then
local_repo=0
fi
ensure_paru() {
if [ ! "$(command -v paru)" ]; then
echo "Installing paru..."
local paru_dir="$cache_dir"/paru
# git clone will return 0 even on error so clean up ahead of time
rm -rf "$paru_dir"
git clone https://aur.archlinux.org/paru-bin.git "$paru_dir" &&
cd "$paru_dir" &&
makepkg -si --noconfirm || return 1
fi
return 0
}
install_base_arch() {
echo "Installing base..."
paru -S --needed --noconfirm --pgpfetch \
archlinux-contrib \
bat \
btop \
byobu \
cargo-binstall \
clang \
coreutils \
gnome-keyring \
kondo \
kitty-terminfo \
libsecret \
man-db \
man-pages \
mosh \
pacman-contrib \
rsync \
sl \
tar \
tree \
unrar \
unzip \
wild \
wget \
&&
# Fish and deps
paru -S --needed --noconfirm --pgpfetch \
fish \
pkgfile \
&&
# Neovim and deps
paru -S --needed --noconfirm --pgpfetch \
fzf \
go \
luarocks \
neovim \
npm \
ripgrep \
rubygems \
&&
# Yazi and deps
paru -S --needed --noconfirm --pgpfetch \
7zip \
chafa\
fd \
ffmpeg \
fzf \
imagemagick \
jq \
poppler \
ripgrep \
yazi \
zoxide \
&&
cargo binstall --no-confirm leptosfmt || return 1
return 0
}
init_browser() {
echo "Setting default browser..."
# Unset BROWSER because xdg gets pissy if it doesn't feel like it's the authority
unset BROWSER &&
xdg-settings set default-web-browser librewolf.desktop &&
# Set it anyway
export BROWSER=librewolf || return 1
return 0
}
init_pywalfox() {
if ! test -f "$HOME"/.librewolf/native-messaging-hosts/pywalfox.json; then
echo "Configuring pywalfox..."
pywalfox install --browser librewolf || return 1
fi
return 0
}
init_wallpaper() {
# Copy default wallpaper if it doesn't exist
if ! test -f "$HOME"/Pictures/Wallpapers/bream.jpg; then
if ! test -d "$HOME"/Pictures/Wallpapers; then
mkdir -p "$HOME"/Pictures/Wallpapers &&
curl -so "$HOME"/Pictures/Wallpapers/bream.jpg https://old.doordesk.net/bream.jpg || return 1
fi
fi
return 0
}
init_wal() {
if ! [ -d "$HOME"/.cache/wal ]; then
bream setbg
else
bream setbg -r
fi || return 1
return 0
}
install_gui_arch() {
paru -S --needed --noconfirm --pgpfetch \
acpi \
bluez \
gnome-themes-extra \
librewolf-bin \
noto-fonts \
noto-fonts-cjk \
noto-fonts-emoji \
otf-commit-mono-nerd \
playerctl \
python-pywalfox-librewolf \
trivalent-bin \
ttf-noto-nerd \
wallust \
zathura \
&&
# Hyprland setup
paru -S --needed --noconfirm --pgpfetch \
cliphist \
dunst \
focal-hyprland-git \
hyprland \
hyprpolkitagent \
kitty \
kitty-shell-integration \
pipewire \
qt5-wayland \
qt6-wayland \
awww-git \
uwsm \
wl-clip-persist \
waybar \
wireplumber \
wofi \
xdg-desktop-portal \
xdg-desktop-portal-gtk \
xdg-desktop-portal-hyprland \
&&
# Set dark theme
# Unset and then reset to ensure it sticks in case dconf doesn't exist
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light' &&
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' &&
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita' &&
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark' &&
# Enable this as a service to keep it out of the config
systemctl --user enable --now hyprpolkitagent.service \
|| return 1
return 0
}
install_extras_arch() {
paru -S --needed --noconfirm --pgpfetch \
discord \
element-desktop \
gimp \
inkscape \
spotify-launcher \
telegram-desktop \
thunderbird \
walogram-git \
&&
# Caprine depends on electon29 and it fails to build from the source it provides
# A bin package exists so we're using it
paru -S --needed --noconfirm --pgpfetch electron29-bin &&
# Ensure caprine comes after its dependency
paru -S --needed --noconfirm --pgpfetch caprine-bin || return 1
return 0
}
install_shell() {
if ! [ "$SHELL" = "/bin/fish" ]; then
sudo chsh -s /bin/fish "$USER" &&
echo "Reboot for changes to take effect"
fi
return 0
}
install_config() {
[ ! -d "$config_dir" ] && { mkdir -p "$config_dir" || return 1; }
cd "$cache_dir"/config &&
for file in *; do
local oldfile="$config_dir"
# TODO: Add clean install option
# [ -e "$oldfile" ] && rm -rf "$oldfile"
cp -r --update=all "$file" "$oldfile" || break
done || return 1
return 0
}
install_bin() {
[ ! -d "$bin_dir" ] && { mkdir -p "$bin_dir" || return 1; }
cd "$cache_dir" &&
sudo cp -r --update=all bin/* "$bin_dir" || return 1
return 0
}
install_home() {
cd "$cache_dir"/home &&
for file in *; do
if [ -d "$file" ]; then
if [ -d "$HOME/.$file" ]; then
cp -r "$file"/* "$HOME"/."$file"/ || break
else
cp -r "$file" "$HOME"/."$file" || break
fi
else
cp "$file" "$HOME"/."$file" || break
fi
done || return 1
return 0
}
cleanup() {
rm -rf "$cache_dir"
}
prepare() {
# Enable pacman colors
sudo sed '/Color/s/^#//' -i /etc/pacman.conf &&
# Enable multi-threading for xz
export XZ_DEFAULTS="-T 0" &&
# grab wild here (wild requires clang) for linking any rust builds during the rest of the install
sudo pacman -S --needed --noconfirm git base-devel clang wild &&
# Make sure .cache exists
if ! [ -d "$HOME"/.cache ]; then
mkdir "$HOME"/.cache
fi &&
# Sync files
if [ "$local_repo" ]; then
cp -r . "$cache_dir"
else
git clone --branch "$git_branch" "$git_url" "$cache_dir"
fi &&
install_bin &&
install_home &&
install_config &&
ensure_paru &&
# Rank mirrors for SPEED
paru -S --needed --noconfirm --pgpfetch rate-mirrors-bin &&
if [ ! "$local_repo" ]; then
bream mirrors
fi || return 1
return 0
}
setup_arch() {
prepare &&
if [ "$1" -ge 1 ]; then
install_base_arch || return 1
fi &&
if [ "$1" -ge 2 ]; then
install_gui_arch &&
init_browser &&
init_pywalfox &&
init_wallpaper &&
init_wal || return 1
fi &&
if [ "$1" -ge 3 ]; then
install_extras_arch || return 1
fi &&
install_shell &&
# this should be last
cleanup || return 1
return 0
}
draw_header() {
clear && echo "$HEADER" || return 1
return 0
}
get_user_input() {
read -r -p 'Choose your adventure:
1. Base shell/CLI stuff only
2. Above plus basic GUI stuff
3. Above plus extras (bloat)
Enter number: ' input &&
# Filter input
if ! [[ "$input" =~ ^[0-9]+$ ]]; then
echo "Error: Not a number"
exit 1
elif [ "$input" -lt 1 ] || [ "$input" -gt 4 ]; then
echo "Error: Input out of range"
exit 1
else
echo "$input"
fi || exit 1
return 0
}
main() {
user_input=$(get_user_input)
draw_header
# Detect OS and act accordingly
. /etc/os-release
local os_name=$NAME
case "$os_name" in
*Arch*)
printf "Setup for %s\n\n" "$os_name"
setup_arch "$user_input" || return 1
;;
*Manjaro*)
printf "Setup for %s\n\n" "$os_name"
setup_arch "$user_input" || return 1
;;
*)
printf "%s is not supported at this time\n" "$os_name"
return 1
;;
esac
return 0
}
draw_header
# Just copy files and exit
if [ "$1" = files ]; then
echo "Copying files..."
cp -r . "$cache_dir" &&
if install_home &&
install_config &&
install_bin &&
cleanup; then
echo "Done" &&
exit 0
else
cleanup
echo "Error"
exit 1
fi
fi
{
main "$@" && exit 0
} || {
echo "Setup failed" &&
cleanup &&
exit 1
}