Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·993 lines (859 loc) · 33 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·993 lines (859 loc) · 33 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
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
#!/usr/bin/env bash
set -euo pipefail
# macOS Tahoe Theme Installer — Hybrid Mode (Interactive TUI default, CLI flags supported)
# Features:
# - Install Tahoe Light/Dark themes
# - Generate accent variants (delegates to generate_accent_variants.py)
# - Install generated color variants
# - Libadwaita override installation (supports specific accent variant)
# - Install Ulauncher theme from GitHub releases
# - Install MacTahoe icons / WhiteSur cursors / WhiteSur GDM
# - Uninstall everything (with confirmation)
# - Fully uses gum where available; falls back to echo/read when not present
#
# Usage:
# ./install.sh -> interactive TUI
# ./install.sh -l -> install light
# ./install.sh -d -> install dark
# ./install.sh -la -> install libadwaita override (requires -l or -d)
# ./install.sh --colors -> generate all accent color variants
# ./install.sh --color blue -> generate specific accent
# ./install.sh -u -> uninstall
# ./install.sh --help -> show help
#
# IMPORTANT: This script delegates color math/generation to generate_accent_variants.py
### ----------------------------
### Configuration / Constants
### ----------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GTK_DIR="$SCRIPT_DIR/gtk"
THEME_DIR="$HOME/.themes"
GTK4_CONFIG_DIR="$HOME/.config/gtk-4.0"
DOWNLOADS_DIR="$(xdg-user-dir DOWNLOAD 2>/dev/null || echo "$HOME/Downloads")"
TMP_DIR="$(mktemp -d -t tahoe-installer.XXXXXXXXXX)"
APP_LAUNCHER="kayozxo/ulauncher-liquid-glass"
TMP_ZIP_AL="ulauncher-liquid-glass.zip"
SRC_DIR="$SCRIPT_DIR/src"
AVAILABLE_COLORS=(blue green purple pink orange red teal indigo rose emerald violet amber cyan lime sky slate)
# Pretty colors for fallback output
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; CYAN='\033[0;36m'
BOLD='\033[1m'; NC='\033[0m'
### ----------------------------
### Utility functions (gum-aware)
### ----------------------------
check_and_install_gum() {
if command -v gum &>/dev/null; then
return 0
fi
# Try best-effort installs (non-exhaustive). If they don't succeed, continue.
echo -e "${YELLOW}gum not found. Attempt automatic install?${NC}"
read -r -p "Install gum (y/N)? " yn
if [[ "$yn" =~ ^[Yy]$ ]]; then
if command -v brew &>/dev/null; then
brew install gum
elif command -v dnf &>/dev/null; then
sudo dnf install -y gum
elif command -v pacman &>/dev/null; then
sudo pacman -S --noconfirm gum
elif command -v apt &>/dev/null; then
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list >/dev/null
sudo apt update && sudo apt install -y gum
else
echo "No known package manager — please install gum manually: https://github.com/charmbracelet/gum"
fi
fi
}
gum_or_echo() {
# usage: gum_or_echo "text"
# Strip ANSI codes if using gum, keep them for echo
if command -v gum &>/dev/null; then
# Remove ANSI escape sequences for gum
local clean_text
clean_text=$(echo -e "$1" | sed 's/\x1b\[[0-9;]*m//g')
gum style --border normal --padding "0 1" "$clean_text"
else
echo -e "$1"
fi
}
gum_confirm_or_read() {
# $1 prompt
if command -v gum &>/dev/null; then
gum confirm "$1"
else
read -r -p "$1 (y/N): " ans
[[ "$ans" =~ ^[Yy]$ ]]
fi
}
gum_choose_lines() {
# pass newline-separated options via stdin; returns selection (stdout)
# If gum missing, fall back to simple numbered selection
if command -v gum &>/dev/null; then
gum choose --cursor ">" --height 8
else
local -a options=()
while IFS= read -r line; do
options+=("$line")
done
if [ ${#options[@]} -eq 0 ]; then
echo "No options available" >&2
return 1
fi
local i=1
for opt in "${options[@]}"; do
echo "$i) $opt" >&2
((i++))
done
local selection
local attempts=0
local max_attempts=3
while [ $attempts -lt $max_attempts ]; do
read -r -p "Enter number (1-${#options[@]}): " selection </dev/tty
if [[ "$selection" =~ ^[0-9]+$ ]] && [ "$selection" -ge 1 ] && [ "$selection" -le "${#options[@]}" ]; then
echo "${options[$((selection-1))]}"
return 0
fi
((attempts++))
if [ $attempts -lt $max_attempts ]; then
echo "Invalid selection. Try again. (Attempt $attempts/$max_attempts)" >&2
fi
done
echo "Max attempts reached. Selection cancelled." >&2
return 1
fi
}
gum_spin_run() {
# $1 title, $2 command string
if command -v gum &>/dev/null; then
gum spin --spinner dot --title "$1" -- bash -c "$2"
else
echo "$1"
bash -c "$2"
fi
}
# safe lowercase and ucfirst helpers
lower() { echo "${1,,}"; } # all lower
upper_first() { echo "${1^}"; } # First letter uppercase
### ----------------------------
### Environment sanity & cleanup
### ----------------------------
cleanup_tmp() {
if [ -n "${TMP_DIR:-}" ] && [ -d "$TMP_DIR" ]; then
rm -rf "$TMP_DIR"
fi
}
trap cleanup_tmp EXIT
mkdir -p "$TMP_DIR" "$THEME_DIR" "$DOWNLOADS_DIR" "$GTK4_CONFIG_DIR"
check_prereqs() {
local missing=()
for cmd in curl git unzip rsync python3; do
if ! command -v "$cmd" &>/dev/null; then
missing+=("$cmd")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
gum_or_echo "${YELLOW}Warning: Missing commands: ${missing[*]}${NC}"
gum_or_echo "${YELLOW}Some features may not work properly.${NC}"
fi
}
### ----------------------------
### Core operations
### ----------------------------
force_reload_theme() {
# Force GNOME to reload theme
gum_or_echo "${CYAN}🔄 Forcing theme reload...${NC}"
# Clear caches
rm -rf ~/.cache/icon-* ~/.cache/gnome-control-center* 2>/dev/null || true
# Reload GTK settings with longer delay for reliability
if command -v gsettings &>/dev/null; then
local current_theme
current_theme=$(gsettings get org.gnome.desktop.interface gtk-theme 2>/dev/null || echo "")
if [ -n "$current_theme" ]; then
gsettings set org.gnome.desktop.interface gtk-theme "" 2>/dev/null || true
sleep 1
gsettings set org.gnome.desktop.interface gtk-theme "$current_theme" 2>/dev/null || true
fi
fi
gum_or_echo "${GREEN}✓ Theme reloaded! You may need to restart applications or log out.${NC}"
echo
}
backup_existing() {
local target="$1"
if [ -d "$target" ] || [ -f "$target" ]; then
local backup="${target}.backup.$(date +%Y%m%d-%H%M%S)"
gum_or_echo "${CYAN}Backing up existing: $(basename "$target") -> $(basename "$backup")${NC}"
mv "$target" "$backup"
fi
}
find_sass_bin() {
# Dart Sass may be installed as `sass` (apt/brew/pacman/npm) or as
# `dart-sass` (the snap package — snap doesn't alias it to `sass` by default).
if command -v sass &>/dev/null; then
command -v sass
elif command -v dart-sass &>/dev/null; then
command -v dart-sass
fi
}
check_and_install_dart_sass() {
if [ -n "$(find_sass_bin)" ]; then
return 0
fi
gum_or_echo "${YELLOW}Dart Sass (sass) not found (required to compile theme SCSS).${NC}"
if ! gum_confirm_or_read "Install Dart Sass now?"; then
gum_or_echo "${YELLOW}Skipping Dart Sass install.${NC}"
return 1
fi
if command -v brew &>/dev/null; then
brew install dart-sass
elif command -v dnf &>/dev/null; then
sudo dnf install -y rubygem-sass || sudo dnf install -y dart-sass
elif command -v pacman &>/dev/null; then
sudo pacman -S --noconfirm dart-sass
elif command -v apt &>/dev/null; then
# dart-sass isn't packaged in apt on newer Ubuntu releases (e.g. 26.04) —
# try apt first, then fall back to snap if it's still missing.
sudo apt update && sudo apt install -y dart-sass || true
if [ -z "$(find_sass_bin)" ] && command -v snap &>/dev/null; then
gum_or_echo "${YELLOW}dart-sass not available via apt — trying snap instead...${NC}"
sudo snap install dart-sass
fi
elif command -v npm &>/dev/null; then
sudo npm install -g sass
else
gum_or_echo "${RED}No known package manager — install Dart Sass manually: https://sass-lang.com/install${NC}"
return 1
fi
if [ -n "$(find_sass_bin)" ]; then
return 0
else
gum_or_echo "${RED}✗ Dart Sass install attempted but command still not found.${NC}"
return 1
fi
}
compile_scss_themes() {
local sass_bin
sass_bin="$(find_sass_bin)"
if [ -z "$sass_bin" ]; then
if check_and_install_dart_sass; then
sass_bin="$(find_sass_bin)"
fi
fi
if [ -z "$sass_bin" ]; then
gum_or_echo "${RED}✗ Dart Sass (sass) is required but not available. Aborting operation.${NC}"
return 1
fi
if [ ! -f "$SRC_DIR/targets/Tahoe-Light-gtk4.scss" ] || [ ! -f "$SRC_DIR/targets/Tahoe-Dark-gtk4.scss" ]; then
gum_or_echo "${RED}✗ SCSS targets not found in $SRC_DIR/targets. Aborting operation.${NC}"
return 1
fi
if ! mkdir -p "$GTK_DIR/Tahoe-Light/gtk-4.0" "$GTK_DIR/Tahoe-Dark/gtk-4.0"; then
gum_or_echo "${RED}✗ Failed to create gtk-4.0 directories.${NC}"
return 1
fi
if ! gum_spin_run "Compiling SCSS -> gtk-4.0 CSS..." "
set -e
'$sass_bin' '$SRC_DIR/targets/Tahoe-Light-gtk4.scss' '$GTK_DIR/Tahoe-Light/gtk-4.0/gtk.css'
'$sass_bin' '$SRC_DIR/targets/Tahoe-Dark-gtk4.scss' '$GTK_DIR/Tahoe-Dark/gtk-4.0/gtk.css'
cp '$GTK_DIR/Tahoe-Light/gtk-4.0/gtk.css' '$GTK_DIR/Tahoe-Light/gtk-4.0/gtk-dark.css'
cp '$GTK_DIR/Tahoe-Dark/gtk-4.0/gtk.css' '$GTK_DIR/Tahoe-Dark/gtk-4.0/gtk-dark.css'
"; then
gum_or_echo "${RED}✗ SCSS compilation failed. Aborting operation.${NC}"
return 1
fi
gum_or_echo "✅ SCSS compiled into gtk-4.0 folders."
return 0
}
install_theme_copy() {
compile_scss_themes || return 1
# args: src_dir dest_name
local src="$1"
local dest_name="$2"
local dest="$THEME_DIR/$dest_name"
if [ -z "$src" ] || [ -z "$dest_name" ]; then
gum_or_echo "${RED}Error: Invalid arguments to install_theme_copy${NC}"
return 1
fi
if [ ! -d "$src" ]; then
gum_or_echo "${YELLOW}Source not found: $src${NC}"
return 1
fi
# Backup existing theme
backup_existing "$dest"
if command -v rsync &>/dev/null; then
gum_spin_run "Installing $dest_name..." "rsync -a \"$src/\" \"$dest/\""
else
gum_spin_run "Installing $dest_name..." "cp -a \"$src\" \"$dest\""
fi
gum_or_echo "✅ Installed $dest_name → $dest"
}
install_base_themes() {
# args: install_light install_dark
local do_light=$1
local do_dark=$2
if $do_light; then
install_theme_copy "$GTK_DIR/Tahoe-Light" "Tahoe-Light"
fi
if $do_dark; then
install_theme_copy "$GTK_DIR/Tahoe-Dark" "Tahoe-Dark"
fi
}
generate_accent_variants_py() {
# args: color (empty -> all)
local color="$1"
if [ ! -f "$SCRIPT_DIR/generate_accent_variants.py" ]; then
gum_or_echo "${RED}Error: generate_accent_variants.py not found in $SCRIPT_DIR${NC}"
return 1
fi
if ! command -v python3 &>/dev/null; then
gum_or_echo "${RED}Error: python3 is required to generate accent variants${NC}"
return 1
fi
if [ -n "$color" ]; then
gum_spin_run "Generating accent: $color" "python3 \"$SCRIPT_DIR/generate_accent_variants.py\" --color \"$color\" --name \"$color\""
else
gum_spin_run "Generating all accent variants..." "python3 \"$SCRIPT_DIR/generate_accent_variants.py\" --all"
fi
gum_or_echo "✅ Accent generation finished."
}
install_color_variants_from_gtkdir() {
local installed_count=0
gum_or_echo "${CYAN}Scanning for generated color variants...${NC}"
shopt -s nullglob
for pattern in "$GTK_DIR"/Tahoe-Dark-* "$GTK_DIR"/Tahoe-Light-*; do
if [ -d "$pattern" ]; then
local bn
bn=$(basename "$pattern")
local dest="$THEME_DIR/$bn"
backup_existing "$dest"
cp -a "$pattern" "$THEME_DIR/"
gum_or_echo " ✓ Installed: $bn"
((installed_count++))
fi
done
shopt -u nullglob
if [ $installed_count -eq 0 ]; then
gum_or_echo "${YELLOW}No generated color variants found in $GTK_DIR${NC}"
gum_or_echo "${YELLOW}Run 'Generate accent variants' first.${NC}"
else
gum_or_echo "${GREEN}🎨 Installed $installed_count accent variant(s) to $THEME_DIR${NC}"
fi
}
install_libadwaita_override() {
compile_scss_themes || return 1
# args: pref_mode(Light|Dark) specific_color(optional)
local pref="$1"
local specific="$2"
# normalize mode to Title Case
pref="${pref:-Light}"
pref="$(upper_first "$(lower "$pref")")"
specific="${specific:-}"
local specific_uc=""
if [ -n "$specific" ]; then
specific_uc="$(upper_first "$(lower "$specific")")"
fi
# First try specific variant paths with Title Case color folder name
local candidate=""
if [ -n "$specific_uc" ]; then
if [ "$pref" = "Light" ] && [ -d "$GTK_DIR/Tahoe-Light-${specific_uc}/gtk-4.0" ]; then
candidate="$GTK_DIR/Tahoe-Light-${specific_uc}/gtk-4.0"
elif [ "$pref" = "Dark" ] && [ -d "$GTK_DIR/Tahoe-Dark-${specific_uc}/gtk-4.0" ]; then
candidate="$GTK_DIR/Tahoe-Dark-${specific_uc}/gtk-4.0"
fi
fi
# Fallback to base gtk-4.0
if [ -z "$candidate" ]; then
if [ "$pref" = "Light" ] && [ -d "$GTK_DIR/Tahoe-Light/gtk-4.0" ]; then
candidate="$GTK_DIR/Tahoe-Light/gtk-4.0"
elif [ "$pref" = "Dark" ] && [ -d "$GTK_DIR/Tahoe-Dark/gtk-4.0" ]; then
candidate="$GTK_DIR/Tahoe-Dark/gtk-4.0"
fi
fi
if [ -z "$candidate" ]; then
gum_or_echo "${RED}✗ libadwaita source folder not found for your selection.${NC}"
gum_or_echo "Tried paths (examples):"
if [ -n "$specific_uc" ]; then
gum_or_echo " $GTK_DIR/Tahoe-${pref}-${specific_uc}/gtk-4.0"
fi
gum_or_echo " $GTK_DIR/Tahoe-${pref}/gtk-4.0"
return 1
fi
# Backup existing gtk-4.0 config
if [ -f "$GTK4_CONFIG_DIR/gtk.css" ]; then
backup_existing "$GTK4_CONFIG_DIR/gtk.css"
fi
gum_spin_run "Installing libadwaita override to $GTK4_CONFIG_DIR..." "
set -e
mkdir -p \"$GTK4_CONFIG_DIR\"
rm -f \"$GTK4_CONFIG_DIR/gtk.css\" \"$GTK4_CONFIG_DIR/gtk-dark.css\" \"$GTK4_CONFIG_DIR/gtk-Light.css\" \"$GTK4_CONFIG_DIR/gtk-Dark.css\" 2>/dev/null || true
rm -rf \"$GTK4_CONFIG_DIR/assets\" \"$GTK4_CONFIG_DIR/windows-assets\" 2>/dev/null || true
cp -a \"$candidate/\"* \"$GTK4_CONFIG_DIR/\"
"
gum_or_echo "✅ Installed libadwaita override from $candidate"
}
install_ulauncher_theme() {
# Requires curl & unzip
if ! command -v curl &>/dev/null || ! command -v unzip &>/dev/null; then
gum_or_echo "${RED}Error: curl and unzip are required to fetch Ulauncher theme${NC}"
return 1
fi
gum_spin_run "Fetching latest release URL for $APP_LAUNCHER..." '
set -e
api=$(curl -s "https://api.github.com/repos/'"$APP_LAUNCHER"'/releases/latest")
DOWNLOAD_URL=$(echo "$api" | grep "\"browser_download_url\"" | sed -E "s/.*\"([^\"]+)\".*/\1/" | head -n1)
echo "$DOWNLOAD_URL" > "'"$TMP_DIR"'/download_url.txt"
'
local url
url="$(cat "$TMP_DIR/download_url.txt" 2>/dev/null || true)"
if [ -z "$url" ]; then
gum_or_echo "${RED}✗ Could not detect download URL from GitHub API for $APP_LAUNCHER${NC}"
return 1
fi
gum_spin_run "Downloading Ulauncher theme..." "curl -L -o \"$TMP_DIR/$TMP_ZIP_AL\" \"$url\""
gum_spin_run "Extracting to $DOWNLOADS_DIR..." "unzip -o \"$TMP_DIR/$TMP_ZIP_AL\" -d \"$DOWNLOADS_DIR\""
rm -f "$TMP_DIR/$TMP_ZIP_AL"
# try to run installer if exists
local install_script
install_script="$(find "$DOWNLOADS_DIR" -maxdepth 2 -type f -iname "install.sh" | head -n1 || true)"
if [ -n "$install_script" ]; then
if gum_confirm_or_read "Run extracted Ulauncher installer ($install_script) now?"; then
bash "$install_script"
gum_or_echo "✅ Ulauncher installer executed."
else
gum_or_echo "⚠️ Installer found at $install_script but not executed."
fi
else
gum_or_echo "✅ Ulauncher package downloaded to $DOWNLOADS_DIR"
fi
}
install_icons_or_cursors() {
# args: repo_url clone_name [install_args...]
local repo="$1"
local dir="$2"
shift 2
local flags=("$@")
local clone_dir="$DOWNLOADS_DIR/$dir"
if [ -d "$clone_dir" ]; then
if gum_confirm_or_read "Folder $clone_dir exists. Remove & re-clone?"; then
rm -rf "$clone_dir"
else
gum_or_echo "Skipping clone."
return 1
fi
fi
gum_spin_run "Cloning $repo..." "git clone --depth=1 \"$repo\" \"$clone_dir\""
gum_or_echo "${YELLOW}⚠️ The following operation will require sudo privileges.${NC}"
if gum_confirm_or_read "Run installer for $dir now (requires sudo)?"; then
sudo bash "$clone_dir/install.sh" "${flags[@]}"
gum_or_echo "✅ Installed $dir"
else
gum_or_echo "⚠️ Cloned to $clone_dir — run installer manually later."
fi
}
install_gdm_theme() {
local repo="https://github.com/vinceliuice/WhiteSur-gtk-theme.git"
local clone_dir="$DOWNLOADS_DIR/WhiteSur-gtk-theme"
if [ -d "$clone_dir" ]; then
if gum_confirm_or_read "WhiteSur GDM folder exists. Remove & re-clone?"; then
rm -rf "$clone_dir"
else
gum_or_echo "Skipping GDM clone."
return 1
fi
fi
gum_spin_run "Cloning WhiteSur GDM theme..." "git clone --depth=1 \"$repo\" \"$clone_dir\""
gum_or_echo "${YELLOW}⚠️ The following operation will require sudo privileges.${NC}"
gum_or_echo "${CYAN}Available backgrounds: default, blank, ...${NC}"
local bg_choice="default"
if command -v gum &>/dev/null; then
bg_choice=$(gum input --placeholder "Enter background (default: default)" --value "default")
else
read -r -p "Enter background choice (default: default): " bg_choice
bg_choice="${bg_choice:-default}"
fi
if gum_confirm_or_read "Install GDM theme with background '$bg_choice' (requires sudo)?"; then
sudo bash "$clone_dir/tweaks.sh" -g -b "$bg_choice"
gum_or_echo "✅ GDM theme installed with background: $bg_choice"
else
gum_or_echo "⚠️ WhiteSur-gtk-theme cloned to $clone_dir"
fi
}
install_wallpaper() {
gum_or_echo "${CYAN}Installing Tahoe 26 5k wallpapers...${NC}"
gum_or_echo "${YELLOW}⚠️ This operation requires sudo privileges to install wallpapers globally.${NC}"
# Check if files exist
local source_wallpaper_dir="$SCRIPT_DIR/.config/walls/Tahoe"
local source_xml="$SCRIPT_DIR/.config/walls/Tahoe.xml"
if [ ! -d "$source_wallpaper_dir" ]; then
gum_or_echo "${RED}✗ Source wallpaper directory not found: $source_wallpaper_dir${NC}"
return 1
fi
if [ ! -f "$source_xml" ]; then
gum_or_echo "${RED}✗ Source XML file not found: $source_xml${NC}"
return 1
fi
# Pre-authenticate sudo before any operations (password prompt will be visible)
gum_or_echo "${YELLOW}⏳ Please enter your sudo password when prompted...${NC}"
if ! sudo -v; then
gum_or_echo "${RED}✗ Failed to authenticate with sudo${NC}"
return 1
fi
# Now run the actual commands - sudo is cached, no prompts during spinner
gum_spin_run "Creating directories..." "sudo mkdir -p /usr/share/backgrounds/ /usr/share/gnome-background-properties/"
gum_spin_run "Copying wallpapers..." "sudo cp -r \"$source_wallpaper_dir\" /usr/share/backgrounds/"
gum_spin_run "Copying metadata..." "sudo cp \"$source_xml\" /usr/share/gnome-background-properties/"
gum_or_echo "✅ Wallpapers installed!"
gum_or_echo "${GREEN}Wallpaper location: /usr/share/backgrounds/Tahoe${NC}"
gum_or_echo "${GREEN}XML location: /usr/share/gnome-background-properties/Tahoe.xml${NC}"
gum_or_echo "${CYAN}Note: You can apply the wallpaper in your settings under Appearance.${NC}"
# Pretty irrelevant information, but so i know you actually check the code: I like kissing boys :3
# wallpaper installer made by skittle0764 https://github.com/skittle0764
}
connect_flatpak() {
if ! command -v flatpak &>/dev/null; then
gum_or_echo "${RED}Error: Flatpak is not installed on your system${NC}"
return 1
fi
gum_or_echo "${CYAN}ℹ️ Flatpak Theme Connection${NC}"
gum_or_echo "This will allow Flatpak apps to access your GTK themes."
echo
gum_or_echo "${YELLOW}⚠️ This operation requires sudo privileges.${NC}"
if ! gum_confirm_or_read "Grant Flatpak apps permission to access GTK configs?"; then
gum_or_echo "Flatpak connection cancelled."
return 0
fi
# Pre-authenticate sudo before any operations
gum_or_echo "${YELLOW}⏳ Please enter your sudo password when prompted...${NC}"
if ! sudo -v; then
gum_or_echo "${RED}✗ Failed to authenticate with sudo${NC}"
return 1
fi
# Grant filesystem access to GTK config directories (sudo is now cached)
gum_spin_run "Granting Flatpak access to GTK-3.0 config..." "sudo flatpak override --filesystem=xdg-config/gtk-3.0"
gum_spin_run "Granting Flatpak access to GTK-4.0 config..." "sudo flatpak override --filesystem=xdg-config/gtk-4.0"
gum_spin_run "Granting Flatpak access to themes..." "sudo flatpak override --filesystem=~/.themes"
gum_or_echo "✅ Flatpak permissions configured successfully!"
echo
gum_or_echo "${GREEN}Your Flatpak apps should now be able to use Tahoe themes.${NC}"
gum_or_echo "${CYAN}Note: You may need to restart Flatpak apps for changes to take effect.${NC}"
}
disconnect_flatpak() {
if ! command -v flatpak &>/dev/null; then
gum_or_echo "${YELLOW}Flatpak is not installed, nothing to disconnect.${NC}"
return 0
fi
gum_or_echo "${CYAN}Disconnecting Flatpak theme access...${NC}"
gum_or_echo "${YELLOW}⚠️ This will remove Flatpak's access to your GTK configs and themes.${NC}"
if ! gum_confirm_or_read "Remove Flatpak GTK theme permissions?"; then
gum_or_echo "Disconnect cancelled."
return 0
fi
# Pre-authenticate sudo before any operations
gum_or_echo "${YELLOW}⏳ Please enter your sudo password when prompted...${NC}"
if ! sudo -v; then
gum_or_echo "${RED}✗ Failed to authenticate with sudo${NC}"
return 1
fi
# Remove filesystem overrides (sudo is now cached)
gum_spin_run "Removing GTK-3.0 access..." "sudo flatpak override --nofilesystem=xdg-config/gtk-3.0 2>/dev/null || true"
gum_spin_run "Removing GTK-4.0 access..." "sudo flatpak override --nofilesystem=xdg-config/gtk-4.0 2>/dev/null || true"
gum_spin_run "Removing themes access..." "sudo flatpak override --nofilesystem=~/.themes 2>/dev/null || true"
gum_or_echo "✅ Flatpak theme permissions removed."
}
uninstall_all() {
if ! gum_confirm_or_read "Are you sure you want to uninstall all Tahoe themes and GTK overrides?"; then
gum_or_echo "Uninstall cancelled."
return 0
fi
gum_spin_run "Removing themes and variants..." '
set -e
if [ -d "'"$THEME_DIR"'/Tahoe-Dark" ]; then rm -rf "'"$THEME_DIR"'/Tahoe-Dark"; fi
if [ -d "'"$THEME_DIR"'/Tahoe-Light" ]; then rm -rf "'"$THEME_DIR"'/Tahoe-Light"; fi
shopt -s nullglob
for d in "'"$THEME_DIR"'/Tahoe-Dark-"* "'"$THEME_DIR"'/Tahoe-Light-"*; do
if [ -d "$d" ]; then rm -rf "$d"; fi
done
'
gum_spin_run "Cleaning $GTK4_CONFIG_DIR..." '
set -e
if [ -f "'"$GTK4_CONFIG_DIR"'/gtk.css" ]; then rm -f "'"$GTK4_CONFIG_DIR"'/gtk.css"; fi
if [ -f "'"$GTK4_CONFIG_DIR"'/gtk-dark.css" ]; then rm -f "'"$GTK4_CONFIG_DIR"'/gtk-dark.css"; fi
if [ -f "'"$GTK4_CONFIG_DIR"'/gtk-Light.css" ]; then rm -f "'"$GTK4_CONFIG_DIR"'/gtk-Light.css"; fi
if [ -f "'"$GTK4_CONFIG_DIR"'/gtk-Dark.css" ]; then rm -f "'"$GTK4_CONFIG_DIR"'/gtk-Dark.css"; fi
if [ -d "'"$GTK4_CONFIG_DIR"'/assets" ]; then rm -rf "'"$GTK4_CONFIG_DIR"'/assets"; fi
if [ -d "'"$GTK4_CONFIG_DIR"'/windows-assets" ]; then rm -rf "'"$GTK4_CONFIG_DIR"'/windows-assets"; fi
'
gum_or_echo "✅ Uninstallation complete."
gum_or_echo "${CYAN}Note: Icons, cursors, and GDM themes may need separate uninstallers.${NC}"
gum_or_echo "${CYAN}Check $DOWNLOADS_DIR for cloned repositories.${NC}"
}
### ----------------------------
### Interactive menu & helpers
### ----------------------------
show_help() {
if command -v gum &>/dev/null; then
gum format --type=markdown <<'MD'
# macOS Tahoe Theme Installer — Help
Run `./install.sh` (interactive TUI). Also supports CLI flags:
## Installation Flags
- `--install-light` or `-l` - Install Tahoe Light theme
- `--install-dark` or `-d` - Install Tahoe Dark theme
- `--install-both` - Install both Light and Dark themes
## Accent Color Flags
- `--colors` - Generate all accent color variants
- `--color NAME` - Generate specific accent variant (e.g., `--color blue`)
## Configuration Flags
- `-la` - Install libadwaita override (use with `-l` or `-d`)
- `--flatpak` - Connect Flatpak apps to Tahoe themes (requires sudo)
- `--flatpak-disconnect` - Remove Flatpak theme access
## Other Flags
- `-u` or `--uninstall` - Uninstall all themes
- `-h` or `--help` - Show this help
## Menu Actions (Interactive Mode)
- **Install Light/Dark/Both** - Copy theme files to ~/.themes
- **Generate accent variants** - Run generate_accent_variants.py
- **Install generated variants** - Copy Tahoe-Light-<color> folders to ~/.themes
- **Libadwaita override** - Install gtk-4.0 override to ~/.config/gtk-4.0
- **Extras** - Install icons, cursors, Ulauncher theme, GDM theme, or connect Flatpak
- **Uninstall** - Remove all installed themes and GTK overrides
## Flatpak Support
Flatpak apps run in a sandbox and need explicit permission to access themes:
1. Run `./install.sh --flatpak` to grant permissions
2. Restart your Flatpak apps to apply the theme
3. Use `--flatpak-disconnect` to remove permissions later
MD
else
cat <<'TXT'
macOS Tahoe Theme Installer — Help
Run ./install.sh to open the interactive TUI.
CLI flags:
--install-light / -l Install Light theme
--install-dark / -d Install Dark theme
--install-both Install both themes
--color NAME Generate specific accent
--colors Generate all accents
-la Install libadwaita override
--flatpak Connect Flatpak themes
--flatpak-disconnect Disconnect Flatpak themes
-u / --uninstall Uninstall all
-h / --help Show help
Flatpak Support:
Grants Flatpak apps permission to use your GTK themes.
Run: ./install.sh --flatpak
TXT
fi
}
choose_accent_color() {
printf "%s\n" "${AVAILABLE_COLORS[@]}" | gum_choose_lines
}
interactive_menu() {
check_prereqs
while true; do
local selection
if command -v gum &>/dev/null; then
selection=$(gum choose --height 14 \
"Install: Light" \
"Install: Dark" \
"Install: Both" \
"Generate: All accent variants" \
"Generate: Specific accent variant" \
"Install generated accent variants into ~/.themes" \
"Install libadwaita override" \
"Install Extras (icons/wallpapers/cursors/ulauncher/GDM)" \
"Uninstall themes" \
"Force reload theme (clear cache)" \
"Help" \
"Exit")
else
echo "Choose an option:"
select selection in "Install: Light" "Install: Dark" "Install: Both" "Generate: All accent variants" "Generate: Specific accent variant" "Install generated accent variants into ~/.themes" "Install libadwaita override" "Install Extras (icons/cursors/ulauncher/GDM)" "Uninstall themes" "Force reload theme" "Help" "Exit"; do break; done
fi
case "$selection" in
"Install: Light") install_base_themes true false || gum_or_echo "${RED}✗ Install failed — back to menu.${NC}" ;;
"Install: Dark") install_base_themes false true || gum_or_echo "${RED}✗ Install failed — back to menu.${NC}" ;;
"Install: Both") install_base_themes true true || gum_or_echo "${RED}✗ Install failed — back to menu.${NC}" ;;
"Generate: All accent variants")
if gum_confirm_or_read "Run accent generation (--all) now?"; then
generate_accent_variants_py ""
fi
;;
"Generate: Specific accent variant")
chosen="$(choose_accent_color)"
if [ -n "${chosen:-}" ]; then
generate_accent_variants_py "$chosen"
else
gum_or_echo "No color chosen — cancelled."
fi
;;
"Install generated accent variants into ~/.themes") install_color_variants_from_gtkdir ;;
"Install libadwaita override")
if command -v gum &>/dev/null; then
mode=$(gum choose "Light" "Dark")
else
read -r -p "Choose mode (Light/Dark): " mode
fi
specific=""
if gum_confirm_or_read "Pick a specific accent variant for libadwaita override?"; then
specific="$(choose_accent_color)"
fi
install_libadwaita_override "${mode:-Light}" "$specific" || gum_or_echo "${RED}✗ libadwaita override failed — back to menu.${NC}"
;;
"Install Extras (icons/wallpapers/cursors/ulauncher/GDM)")
if command -v gum &>/dev/null; then
ex=$(gum choose \
"Install MacTahoe icons" \
"Install WhiteSur cursors" \
"Install Ulauncher theme" \
"Install WhiteSur GDM theme" \
"Install Tahoe Wallpapers" \
"Connect Flatpak themes" \
"Disconnect Flatpak themes" \
"Back")
else
echo "Extras:"
echo " 1) Install MacTahoe icons"
echo " 2) Install WhiteSur cursors"
echo " 3) Install Ulauncher theme"
echo " 4) Install WhiteSur GDM theme"
echo " 5) Install Tahoe Wallpapers"
echo " 6) Connect Flatpak themes"
echo " 7) Disconnect Flatpak themes"
echo " 8) Back"
read -r -p "Enter choice (1-8): " ex
fi
case "$ex" in
"Install MacTahoe icons"|1) install_icons_or_cursors "https://github.com/vinceliuice/MacTahoe-icon-theme.git" "MacTahoe-icon-theme" -b ;;
"Install WhiteSur cursors"|2) install_icons_or_cursors "https://github.com/vinceliuice/WhiteSur-cursors.git" "WhiteSur-cursors" ;;
"Install Ulauncher theme"|3) install_ulauncher_theme ;;
"Install WhiteSur GDM theme"|4) install_gdm_theme ;;
"Install Tahoe Wallpapers"|5) install_wallpaper ;;
"Connect Flatpak themes"|6) connect_flatpak ;;
"Disconnect Flatpak themes"|7) disconnect_flatpak ;;
"Back"|8) : ;;
*) gum_or_echo "${YELLOW}Unrecognized option in Extras menu${NC}" ;;
esac
;;
"Uninstall themes") uninstall_all ;;
"Force reload theme"|"Force reload theme (clear cache)") force_reload_theme ;;
"Help") show_help ;;
"Exit") gum_or_echo "Goodbye — enjoy the theme! 🎉"; break ;;
*) gum_or_echo "${YELLOW}Unrecognized option${NC}" ;;
esac
# small refresh
if command -v gum &>/dev/null; then
gum spin --spinner line --title "Refreshing..." -- sleep 0.12
else
sleep 0.12
fi
done
}
### ----------------------------
### CLI flag handling (hybrid)
### ----------------------------
print_usage_and_exit() {
show_help
exit 0
}
# Parse CLI options first (before interactive mode)
if [[ $# -gt 0 ]]; then
# Handle help first
for arg in "$@"; do
if [[ "$arg" == "--help" || "$arg" == "-h" ]]; then
print_usage_and_exit
fi
done
# Parse combined flags like -l -la or -d --color blue -la
INSTALL_LIGHT=false
INSTALL_DARK=false
INSTALL_LIBADWAITA=false
INSTALL_COLORS=false
SPECIFIC_COLOR=""
INSTALL_WALLPAPER=false
while [[ $# -gt 0 ]]; do
case "$1" in
-u|--uninstall)
uninstall_all
exit 0
;;
-l|--install-light)
INSTALL_LIGHT=true
shift
;;
-d|--install-dark)
INSTALL_DARK=true
shift
;;
-la)
INSTALL_LIBADWAITA=true
shift
;;
-w|--wallpaper)
INSTALL_WALLPAPER=true
shift
;;
--flatpak)
connect_flatpak
exit 0
;;
--flatpak-disconnect)
disconnect_flatpak
exit 0
;;
--colors)
INSTALL_COLORS=true
shift
;;
--color)
INSTALL_COLORS=true
SPECIFIC_COLOR="$2"
shift 2
;;
--install-both)
INSTALL_LIGHT=true
INSTALL_DARK=true
shift
;;
*)
gum_or_echo "${YELLOW}Unknown option: $1${NC}"
print_usage_and_exit
;;
esac
done
# Execute based on parsed flags
if $INSTALL_LIGHT || $INSTALL_DARK; then
install_base_themes $INSTALL_LIGHT $INSTALL_DARK || { gum_or_echo "${RED}✗ Theme installation failed.${NC}"; exit 1; }
fi
if $INSTALL_COLORS; then
if [ -n "$SPECIFIC_COLOR" ]; then
generate_accent_variants_py "$SPECIFIC_COLOR"
else
generate_accent_variants_py ""
fi
fi
if $INSTALL_LIBADWAITA; then
# Determine mode from flags
pref="Light"
if $INSTALL_DARK; then
pref="Dark"
elif ! $INSTALL_LIGHT && ! $INSTALL_DARK; then
pref="Light" # default
fi
install_libadwaita_override "$pref" "$SPECIFIC_COLOR" || { gum_or_echo "${RED}✗ libadwaita override failed.${NC}"; exit 1; }
fi
if $INSTALL_WALLPAPER; then
install_wallpaper
fi
exit 0
fi
### ----------------------------
### Start interactive TUI (default)
### ----------------------------
check_and_install_gum
check_prereqs
if command -v gum &>/dev/null; then
gum style --border double --padding "1 2" --margin "1" --foreground 212 "🌄 macOS Tahoe Theme Installer" "Welcome! Let's make your desktop beautiful."
else
echo -e "${BOLD}macOS Tahoe Theme Installer — Interactive${NC}"
fi
interactive_menu
exit 0