-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·582 lines (492 loc) · 17.2 KB
/
setup.sh
File metadata and controls
executable file
·582 lines (492 loc) · 17.2 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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
#!/bin/bash
set -euo pipefail
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Ensure gum is available
if ! command -v gum &>/dev/null; then
echo "Installing gum..."
sudo dnf install -y gum
fi
# Helper: install flatpak app
install_flatpak() {
flatpak install -y flathub "$@"
}
# Helper: install dnf packages
install_dnf() {
sudo dnf install -y "$@"
}
# Helper: stow dotfiles
stow_dotfiles() {
local pkg="$1"
if ! command -v stow &>/dev/null; then
gum style --foreground 33 "Installing stow..."
install_dnf stow
fi
if ! command -v git &>/dev/null; then
gum style --foreground 33 "Installing git..."
install_dnf git
fi
gum style --foreground 33 "Configuring $pkg..."
stow -d "$DOTFILES_DIR" -t "$HOME" --adopt "$pkg"
git -C "$DOTFILES_DIR" checkout -- "$pkg"
}
# System update
update_system() {
gum style --foreground 33 "Updating system..."
sudo dnf upgrade -y --refresh
}
# Faster DNF downloads
configure_dnf() {
grep -q "max_parallel_downloads" /etc/dnf/dnf.conf && return
gum style --foreground 33 "Configuring DNF for faster downloads..."
echo -e "max_parallel_downloads=10\nfastestmirror=True" | sudo tee -a /etc/dnf/dnf.conf
}
# Disable NetworkManager-wait-online (faster boot)
disable_nm_wait() {
gum style --foreground 33 "Disabling NetworkManager-wait-online..."
sudo systemctl disable NetworkManager-wait-online.service 2>/dev/null || true
}
# Flathub repository
configure_flathub() {
gum style --foreground 33 "Adding Flathub repository..."
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
}
# RPM Fusion repositories (free + nonfree)
install_rpmfusion() {
gum style --foreground 33 "Enabling RPM Fusion repositories..."
sudo dnf install -y \
https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
sudo dnf group upgrade -y core
}
# Full multimedia support (FFmpeg, GStreamer, codecs)
install_multimedia() {
gum style --foreground 33 "Installing multimedia packages..."
sudo dnf swap -y ffmpeg-free ffmpeg --allowerasing
sudo dnf group install -y multimedia
}
# Intel hardware video acceleration (VA-API)
install_intel_vaapi() {
gum style --foreground 33 "Installing Intel media driver..."
install_dnf intel-media-driver libva-utils
}
# Intel compute runtime (OpenCL, Level Zero)
install_intel_compute() {
gum style --foreground 33 "Installing Intel compute runtime..."
install_dnf intel-compute-runtime intel-level-zero intel-igc intel-ocloc
}
# Fonts
install_fonts() {
gum style --foreground 33 "Installing fonts..."
install_dnf jetbrains-mono-fonts cascadia-mono-fonts rsms-inter-fonts
}
configure_fonts() {
gum style --foreground 33 "Configuring fonts..."
gsettings set org.gnome.desktop.interface font-name 'Inter 10'
gsettings set org.gnome.desktop.interface document-font-name 'Inter 10'
gsettings set org.gnome.desktop.interface monospace-font-name 'JetBrains Mono 10'
gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Inter Bold 10'
gsettings set org.gnome.desktop.interface font-antialiasing 'grayscale'
gsettings set org.gnome.desktop.interface font-hinting 'slight'
}
# GNOME
configure_gnome() {
gum style --foreground 33 "Configuring GNOME..."
gsettings set org.gnome.desktop.wm.preferences button-layout 'appmenu:'
gsettings set org.gnome.desktop.wm.keybindings close "['<Super>q']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<Alt>1']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-2 "['<Alt>2']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-3 "['<Alt>3']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-4 "['<Alt>4']"
gsettings set org.gnome.desktop.interface clock-format '24h'
gsettings set org.gnome.desktop.interface clock-show-weekday true
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']"
gsettings set org.gnome.desktop.interface scaling-factor 2
gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 20
gsettings set org.gnome.desktop.peripherals.keyboard delay 200
gsettings set org.gnome.desktop.interface enable-hot-corners false
gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click false
gsettings set org.gnome.mutter dynamic-workspaces false
gsettings set org.gnome.desktop.wm.preferences num-workspaces 4
gsettings set org.gnome.GWeather4 temperature-unit 'centigrade'
}
install_gnome_extension() {
local ext="$1"
local ext_dir="$HOME/.local/share/gnome-shell/extensions/$ext"
[[ -d "$ext_dir" ]] && return
gdbus call --session \
--dest org.gnome.Shell.Extensions \
--object-path /org/gnome/Shell/Extensions \
--method org.gnome.Shell.Extensions.InstallRemoteExtension \
"$ext" >/dev/null 2>&1 || true
}
install_gnome_extensions() {
gum style --foreground 33 "Installing GNOME extensions..."
install_gnome_extension just-perfection-desktop@just-perfection
install_gnome_extension tactile@lundal.io
install_gnome_extension disable-workspace-animation@ethnarque
}
configure_gnome_extensions() {
gum style --foreground 33 "Configuring GNOME extensions..."
dconf write /org/gnome/shell/extensions/just-perfection/animation 4
dconf write /org/gnome/shell/extensions/just-perfection/workspace-popup false
dconf write /org/gnome/shell/extensions/just-perfection/startup-status 0
dconf write /org/gnome/shell/extensions/tactile/show-tiles "['<Super>Return']"
dconf write /org/gnome/shell/extensions/tactile/grid-rows 2
dconf write /org/gnome/shell/extensions/tactile/grid-cols 4
dconf write /org/gnome/shell/extensions/tactile/row-0 0
dconf write /org/gnome/shell/extensions/tactile/row-1 1
dconf write /org/gnome/shell/extensions/tactile/col-0 1
dconf write /org/gnome/shell/extensions/tactile/col-1 3
dconf write /org/gnome/shell/extensions/tactile/col-2 3
dconf write /org/gnome/shell/extensions/tactile/col-3 1
}
# Git
configure_git() { stow_dotfiles gitconfig; }
# CLI tools (zoxide, ripgrep, fzf, gh)
install_cli_tools() {
gum style --foreground 33 "Installing CLI tools..."
install_dnf zoxide ripgrep fd-find fzf gh htop btop nvtop stow jq mosh
}
# mise runtime manager
install_mise() {
command -v mise &>/dev/null && return
gum style --foreground 33 "Installing mise..."
sudo dnf copr enable -y jdxcode/mise
install_dnf mise
}
configure_mise() {
stow_dotfiles mise
mise install
}
# direnv
install_direnv() {
gum style --foreground 33 "Installing direnv..."
install_dnf direnv
}
configure_direnv() { stow_dotfiles direnv; }
# uv package manager
install_uv() {
export PATH="$HOME/.local/bin:$PATH"
command -v uv &>/dev/null && return
gum style --foreground 33 "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
}
# Ampcode CLI
install_ampcode() {
command -v amp &>/dev/null && return
gum style --foreground 33 "Installing Ampcode..."
curl -fsSL https://ampcode.com/install.sh | bash
}
# Python versions via uv
install_python() {
gum style --foreground 33 "Installing Python versions..."
uv python install 3.11 3.12 3.13
}
# Dev tools via uv
install_dev_tools() {
gum style --foreground 33 "Installing dev tools..."
uv tool install ruff
uv tool install ty
uv tool install taplo
}
# SQLite database
install_sqlite() {
gum style --foreground 33 "Installing SQLite..."
install_dnf sqlite
}
configure_sqlite() { stow_dotfiles sqlite; }
# Chromium browser
chromium_profile_name() {
local chromium_dir="$HOME/.config/chromium"
local dir_name="$1"
jq -r --arg dir "$dir_name" '.profile.info_cache[$dir].name // $dir' "$chromium_dir/Local State"
}
chromium_choose_profile() {
local header="$1"
local chromium_dir="$HOME/.config/chromium"
declare -A profile_map
for dir in "$chromium_dir"/*/; do
if [[ -f "$dir/Bookmarks" || -f "$dir/History" ]]; then
local dir_name
dir_name=$(basename "$dir")
local display_name
display_name=$(chromium_profile_name "$dir_name")
profile_map["$display_name"]="$dir_name"
fi
done
if [[ ${#profile_map[@]} -eq 0 ]]; then
gum style --foreground 196 "No Chromium profiles found" >&2
return 1
fi
local selection
selection=$(printf '%s\n' "${!profile_map[@]}" | gum choose --header "$header")
[[ -z "$selection" ]] && return 1
echo "${profile_map[$selection]}"
}
install_chromium() {
gum style --foreground 33 "Installing Chromium..."
install_dnf chromium
}
configure_chromium() {
gum style --foreground 33 "Configuring Chromium..."
local target="$HOME/.local/share/applications/chromium-browser.desktop"
mkdir -p "$HOME/.local/share/applications"
sed 's|Exec=\(.*chromium-browser\)|Exec=\1 --enable-features=TouchpadOverscrollHistoryNavigation|' \
/usr/share/applications/chromium-browser.desktop >"$target"
}
backup_chromium() {
local chromium_dir="$HOME/.config/chromium"
local profile_dir_name
profile_dir_name=$(chromium_choose_profile "Select Chromium profile:")
[[ -z "$profile_dir_name" ]] && return 1
local profile_dir="$chromium_dir/$profile_dir_name"
local profile_name
profile_name=$(chromium_profile_name "$profile_dir_name")
local default_path="$DOTFILES_DIR/backups/chromium-$profile_name-$(date +%Y%m%d-%H%M%S).tar.gz"
local archive
archive=$(gum input --placeholder "$default_path" --header "Save backup to:" --value "$default_path")
[[ -z "$archive" ]] && return 1
mkdir -p "$(dirname "$archive")"
local files=()
[[ -f "$profile_dir/Bookmarks" ]] && files+=("Bookmarks")
[[ -f "$profile_dir/History" ]] && files+=("History")
[[ -f "$profile_dir/Favicons" ]] && files+=("Favicons")
tar -czf "$archive" -C "$profile_dir" "${files[@]}"
gum style --foreground 28 "✓ Chromium backup created: $archive"
}
restore_chromium() {
local backup_dir="$DOTFILES_DIR/backups"
local chromium_dir="$HOME/.config/chromium"
if pgrep -x chromium &>/dev/null; then
gum style --foreground 196 "Please close Chromium before restoring"
return 1
fi
# Pick backup
local backup
backup=$(gum file "$backup_dir")
[[ -z "$backup" || ! -f "$backup" ]] && return 1
# Pick target profile
local profile
profile=$(chromium_choose_profile "Restore to profile:")
[[ -z "$profile" ]] && return 1
local profile_name
profile_name=$(chromium_profile_name "$profile")
# Confirm
gum confirm "Restore $(basename "$backup") to $profile_name?" || return 1
# Extract
tar -xzf "$backup" -C "$chromium_dir/$profile"
gum style --foreground 28 "✓ Restored $(basename "$backup") to $profile_name"
}
# Bitwarden password manager
install_bitwarden() {
gum style --foreground 33 "Installing Bitwarden..."
install_flatpak com.bitwarden.desktop
}
# Eyedropper color picker
install_eyedropper() {
gum style --foreground 33 "Installing Eyedropper..."
install_flatpak com.github.finefindus.eyedropper
}
# Extension Manager
install_extension_manager() {
gum style --foreground 33 "Installing Extension Manager..."
install_flatpak com.mattjakeman.ExtensionManager
}
# GNOME Tweaks
install_gnome_tweaks() {
gum style --foreground 33 "Installing GNOME Tweaks..."
install_dnf gnome-tweaks
}
# Gear Lever (AppImage manager)
install_gear_lever() {
gum style --foreground 33 "Installing Gear Lever..."
install_flatpak it.mijorus.gearlever
}
# Spotify
install_spotify() {
gum style --foreground 33 "Installing Spotify..."
install_flatpak com.spotify.Client
}
# LocalSend
install_localsend() {
gum style --foreground 33 "Installing LocalSend..."
install_flatpak org.localsend.localsend_app
}
# Ghostty terminal
install_ghostty() {
command -v ghostty &>/dev/null && return
gum style --foreground 33 "Installing Ghostty..."
sudo dnf copr enable -y scottames/ghostty
install_dnf ghostty
}
configure_ghostty() { stow_dotfiles ghostty; }
# Helix text editor
install_helix() {
gum style --foreground 33 "Installing Helix..."
install_dnf helix
}
configure_helix() { stow_dotfiles helix; }
# Gradia screen annotation tool
install_gradia() {
gum style --foreground 33 "Installing Gradia..."
install_flatpak be.alexandervanhee.gradia
}
configure_gradia() {
gum style --foreground 33 "Configuring Gradia..."
local path="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/gradia/"
local key="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"
dconf write "${path}name" "'Gradia Screenshot'"
dconf write "${path}command" "'flatpak run be.alexandervanhee.gradia --screenshot=INTERACTIVE'"
dconf write "${path}binding" "'<Super><Shift>s'"
local current
current=$(dconf read "$key" 2>/dev/null || echo "@as []")
if [[ -z "$current" || "$current" == "@as []" ]]; then
dconf write "$key" "['$path']"
elif [[ "$current" != *"$path"* ]]; then
dconf write "$key" "${current%]},'$path']"
fi
}
# Tailscale VPN
install_tailscale() {
gum style --foreground 33 "Installing Tailscale..."
sudo dnf config-manager addrepo --overwrite --from-repofile=https://pkgs.tailscale.com/stable/fedora/tailscale.repo
install_dnf tailscale
sudo systemctl enable --now tailscaled
}
# WWAN unlock for Lenovo ThinkPad (Quectel RM520N-GL)
install_wwan_unlock() {
[[ -d /opt/fcc_lenovo ]] && return
gum style --foreground 33 "Installing Lenovo WWAN unlock..."
local tmpdir=$(mktemp -d)
git clone --depth 1 https://github.com/lenovo/lenovo-wwan-unlock "$tmpdir"
sudo "$tmpdir/fcc_unlock_setup.sh"
rm -rf "$tmpdir"
}
# WWAN dispatcher fix for MBIM over MHI
install_wwan_fix() {
local target="/etc/NetworkManager/dispatcher.d/99-wwan-fix"
[[ -e "$target" ]] && return
gum style --foreground 33 "Installing WWAN dispatcher fix..."
sudo stow -d "$DOTFILES_DIR" -t / wwan
sudo chmod +x "$target"
}
# WWAN access point configuration
configure_wwan_apn() {
nmcli -t -f NAME connection show | grep -q "^Orange Internet$" && return
gum style --foreground 33 "Configuring WWAN access point..."
nmcli -t -f NAME,TYPE connection show | { grep ':gsm$' || true; } | cut -d: -f1 | while read -r conn; do
nmcli connection delete "$conn" || true
done
nmcli connection add type gsm con-name "Orange Internet" \
gsm.apn "internet" \
gsm.username "internet" \
gsm.password "internet" \
gsm.home-only yes \
connection.autoconnect no
}
# Fish shell
install_fish() {
gum style --foreground 33 "Installing Fish..."
install_dnf fish
}
configure_fish() {
stow_dotfiles fish
[[ "$SHELL" == *"fish"* ]] && return
gum style --foreground 33 "Setting Fish as default shell..."
chsh -s "$(command -v fish)" "$USER"
}
# Remove PyCharm COPR repo
remove_pycharm_repo() {
if ! dnf repolist --all | grep -q "phracek:PyCharm"; then
return 0
fi
gum style --foreground 33 "Removing PyCharm COPR repo..."
sudo dnf copr remove -y phracek/PyCharm
}
# Disable fingerprint for sudo
disable_sudo_fingerprint() {
grep -q "pam_unix.so" /etc/pam.d/sudo && return
gum style --foreground 33 "Disabling fingerprint for sudo..."
sudo sed -i.bak 's/^auth\s*include\s*system-auth/auth required pam_unix.so/' /etc/pam.d/sudo
}
# Project directories
create_project_dirs() {
gum style --foreground 33 "Creating project directories..."
mkdir -p "$HOME/proj" "$HOME/fun"
}
main() {
# Cleanup
remove_pycharm_repo
# System
update_system
configure_dnf
disable_nm_wait
disable_sudo_fingerprint
configure_flathub
install_rpmfusion
# Multimedia
install_multimedia
install_intel_vaapi
install_intel_compute
# Fonts
install_fonts
configure_fonts
# GNOME
configure_gnome
install_gnome_extensions
configure_gnome_extensions
# Dev tools
configure_git
install_cli_tools
install_mise
configure_mise
install_direnv
configure_direnv
install_uv
install_ampcode
install_python
install_dev_tools
install_sqlite
configure_sqlite
# Apps
install_chromium
configure_chromium
install_ghostty
configure_ghostty
install_helix
configure_helix
install_bitwarden
install_gradia
configure_gradia
install_eyedropper
install_extension_manager
install_gnome_tweaks
install_gear_lever
install_spotify
install_localsend
# Network
install_tailscale
install_wwan_unlock
install_wwan_fix
configure_wwan_apn
# Shell (last, requires re-login)
install_fish
configure_fish
# Directories
create_project_dirs
echo ""
gum style --foreground 28 --bold "Setup complete!"
echo ""
gum style --faint "Restart for all changes to take effect."
echo ""
if gum confirm "Restart now?" --default=false; then
systemctl reboot
fi
}
cmd="${1:-main}"
if declare -F "$cmd" >/dev/null; then
"$cmd"
else
echo "Unknown command: $cmd" >&2
exit 1
fi