-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
127 lines (92 loc) · 3.66 KB
/
install.sh
File metadata and controls
127 lines (92 loc) · 3.66 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
#!/usr/bin/env bash
set -euo pipefail
REPO="https://github.com/atif-1402/minimal-waybar-themes.git"
CONFIG_DIR="$HOME/.config/waybar"
TMP_DIR=$(mktemp -d)
# ===== Cleanup temp folder =====
cleanup() {
rm -rf "$TMP_DIR" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
# ===== Dependency Check =====
for cmd in git gum; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo
echo "Missing dependency: $cmd"
echo
echo "This is required to run the Waybar Theme Installer interface."
echo "Please install it before continuing."
echo
echo "Example (Arch Linux): sudo pacman -S $cmd"
echo
exit 1
fi
done
clear
gum style --border rounded --padding "1 4" --align center \
"
██ ██ ▄▄▄ ▄▄ ▄▄ ▄▄▄▄ ▄▄▄ ▄▄▄▄ ██████ ▄▄ ▄▄ ▄▄▄▄▄ ▄▄ ▄▄ ▄▄▄▄▄ ▄▄▄▄
██ ▄█▄ ██ ██▀██ ▀███▀ ██▄██ ██▀██ ██▄█▄ ██ ██▄██ ██▄▄ ██▀▄▀██ ██▄▄ ███▄▄
▀██▀██▀ ██▀██ █ ██▄█▀ ██▀██ ██ ██ ██ ██ ██ ██▄▄▄ ██ ██ ██▄▄▄ ▄▄██▀
by atif-1402 "
echo
gum style "This will install a Waybar theme by atif-1402 on your system."
echo
# ===== Step 1 =====
gum style --foreground 212 "Step 1/4 — Downloading theme list..."
gum spin --spinner dot --title "Cloning repository..." -- \
git clone --depth 1 "$REPO" "$TMP_DIR" >/dev/null 2>&1
if [ ! -d "$TMP_DIR/waybar" ]; then
gum style --foreground 1 "Error: Could not fetch themes."
exit 1
fi
# ===== Step 2 =====
gum style --foreground 212 "Step 2/4 — Choose a theme"
THEMES=$(find "$TMP_DIR/waybar" \
-mindepth 1 -maxdepth 1 -type d -printf "%f\n" | sort -V)
COUNT=$(echo "$THEMES" | wc -l)
theme=$(printf "%s\n" $THEMES | \
gum choose --header "$COUNT themes available (scroll to view more)")
[ -z "$theme" ] && exit 0
# ===== Step 3 =====
gum style --foreground 212 "Step 3/4 — Installing $theme"
BACKUP_CREATED="no"
if [ -d "$CONFIG_DIR" ]; then
BACKUP="$HOME/.config/waybar.backup.$(date +%s)"
mv "$CONFIG_DIR" "$BACKUP"
BACKUP_CREATED="yes"
fi
mkdir -p "$CONFIG_DIR"
gum spin --spinner dot --title "Copying files..." -- \
cp -rf "$TMP_DIR/waybar/$theme/." "$CONFIG_DIR"
# Detect scripts
SCRIPT_COUNT=$(find "$CONFIG_DIR" -type f -name "*.sh" | wc -l)
if [ "$SCRIPT_COUNT" -gt 0 ]; then
find "$CONFIG_DIR" -type f -name "*.sh" -exec chmod +x {} \;
SCRIPTS_MESSAGE="Detected $SCRIPT_COUNT script file(s) and made them executable."
else
SCRIPTS_MESSAGE="No scripts detected in this theme. You are good to go!."
fi
# ===== Step 4 =====
gum style --foreground 212 "Step 4/4 — Restarting Waybar"
# Kill safely
pkill -x waybar 2>/dev/null || true
sleep 0.5
# Restart properly depending on compositor
if command -v hyprctl >/dev/null 2>&1; then
hyprctl dispatch exec waybar >/dev/null 2>&1
else
nohup waybar >/dev/null 2>&1 &
fi
echo
FINAL_MESSAGE="Theme '$theme' installed successfully."
if [ "$BACKUP_CREATED" = "yes" ]; then
FINAL_MESSAGE="$FINAL_MESSAGE
A backup of your previous configuration was created at:
$BACKUP"
fi
FINAL_MESSAGE="$FINAL_MESSAGE
$SCRIPTS_MESSAGE"
gum style --border rounded --padding "1 3" "$FINAL_MESSAGE"
echo
read -p "Press Enter to exit..."