-
-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
Β·240 lines (200 loc) Β· 7.5 KB
/
setup.sh
File metadata and controls
executable file
Β·240 lines (200 loc) Β· 7.5 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
#!/bin/bash
## SDDM Astronaut Theme Installer
## Based on original by Keyitdev https://github.com/Keyitdev/sddm-astronaut-theme
## Copyright (C) 2022-2025 Keyitdev
# Script works in Arch, Fedora, Ubuntu. Didn't tried in Void and openSUSE
set -euo pipefail
readonly THEME_REPO="https://github.com/Keyitdev/sddm-astronaut-theme.git"
readonly THEME_NAME="sddm-astronaut-theme"
readonly THEMES_DIR="/usr/share/sddm/themes"
readonly PATH_TO_GIT_CLONE="$HOME/$THEME_NAME"
readonly METADATA="$THEMES_DIR/$THEME_NAME/metadata.desktop"
readonly DATE=$(date +%s)
readonly -a THEMES=(
"astronaut" "black_hole" "cyberpunk" "hyprland_kath" "jake_the_dog"
"japanese_aesthetic" "pixel_sakura" "pixel_sakura_static"
"post-apocalyptic_hacker" "purple_leaves"
)
# Logging with gum fallback
info() {
if command -v gum &>/dev/null; then
gum style --foreground 10 "β
$*"
else
echo -e "\e[32mβ
$*\e[0m"
fi
}
warn() {
if command -v gum &>/dev/null; then
gum style --foreground 11 "β $*"
else
echo -e "\e[33mβ $*\e[0m"
fi
}
error() {
if command -v gum &>/dev/null; then
gum style --foreground 9 "β $*" >&2
else
echo -e "\e[31mβ $*\e[0m" >&2
fi
}
# UI functions
confirm() {
if command -v gum &>/dev/null; then
gum confirm "$1"
else
echo -n "$1 (y/n): "; read -r r; [[ "$r" =~ ^[Yy]$ ]]
fi
}
choose() {
if command -v gum &>/dev/null; then
gum choose --cursor.foreground 12 --header="" --header.foreground 12 "$@"
else
select opt in "$@"; do [[ -n "$opt" ]] && { echo "$opt"; break; }; done
fi
}
spin() {
local title="$1"; shift
if command -v gum &>/dev/null; then
gum spin --spinner="dot" --title="$title" -- "$@"
else
echo "$title"; "$@"
fi
}
# Install gum if missing
install_gum() {
local mgr=$(for m in pacman xbps-install dnf zypper apt; do command -v $m &>/dev/null && { echo $m; break; }; done)
case $mgr in
pacman) sudo pacman -S gum ;;
dnf) sudo dnf install -y gum ;;
zypper) sudo zypper install -y gum ;;
xbps-install) sudo xbps-install -y gum ;;
# refrence https://github.com/basecamp/omakub/issues/222
apt)
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
sudo apt update && sudo apt install -y gum ;;
*) error "Cannot install gum automatically"; return 1 ;;
esac
}
# Check and install gum
check_gum() {
if ! command -v gum &>/dev/null; then
warn "Gum was not found - provides better UI experience"
if confirm "Install gum?"; then
install_gum && { info "Restarting with gum..."; main; } || warn "Using fallback UI"
fi
fi
}
# Install dependencies
install_deps() {
local mgr=$(for m in pacman xbps-install dnf zypper apt; do command -v $m &>/dev/null && { echo $m; break; }; done)
info "Package manager: $mgr"
case $mgr in
pacman) sudo pacman --needed -S sddm qt6-svg qt6-virtualkeyboard qt6-multimedia-ffmpeg ;;
xbps-install) sudo xbps-install -y sddm qt6-svg qt6-virtualkeyboard qt6-multimedia ;;
dnf) sudo dnf install -y sddm qt6-qtsvg qt6-qtvirtualkeyboard qt6-qtmultimedia ;;
zypper) sudo zypper install -y sddm libQt6Svg6 qt6-virtualkeyboard qt6-multimedia ;;
apt) sudo apt update && sudo apt install -y sddm qt6-svg-dev qml6-module-qtquick-virtualkeyboard qt6-multimedia-dev ;;
*) error "Unsupported package manager"; return 1 ;;
esac
info "Dependencies installed"
}
# Clone repository
clone_repo() {
[[ -d "$PATH_TO_GIT_CLONE" ]] && mv "$PATH_TO_GIT_CLONE" "${PATH_TO_GIT_CLONE}_$DATE"
spin "Cloning repository..." git clone -b master --depth 1 "$THEME_REPO" "$PATH_TO_GIT_CLONE"
info "Repository cloned to $PATH_TO_GIT_CLONE"
}
# Install theme
install_theme() {
local src="$HOME/$THEME_NAME"
local dst="$THEMES_DIR/$THEME_NAME"
[[ ! -d "$src" ]] && { error "Clone repository first"; return 1;}
# Backup and copy
[[ -d "$dst" ]] && sudo mv "$dst" "${dst}_$DATE"
sudo mkdir -p "$dst"
spin "Installing theme files..." sudo cp -r "$src"/* "$dst"/
# Install fonts
[[ -d "$dst/Fonts" ]] && spin "Installing fonts..." sudo cp -r "$dst/Fonts"/* /usr/share/fonts/
# Configure SDDM
echo "[Theme]
Current=$THEME_NAME" | sudo tee /etc/sddm.conf >/dev/null
sudo mkdir -p /etc/sddm.conf.d
echo "[General]
InputMethod=qtvirtualkeyboard" | sudo tee /etc/sddm.conf.d/virtualkbd.conf >/dev/null
info "Theme installed"
}
# Select theme variant
select_theme() {
[[ ! -f "$METADATA" ]] && { error "Install theme first"; return 1; }
local theme=$(choose "${THEMES[@]}" || echo "astronaut")
sudo sed -i "s|^ConfigFile=.*|ConfigFile=Themes/${theme}.conf|" "$METADATA"
info "Selected theme: $theme"
}
# Enable SDDM
enable_sddm() {
command -v systemctl &>/dev/null || { error "systemctl not found"; return 1; }
sudo systemctl disable display-manager.service 2>/dev/null || true
sudo systemctl enable sddm.service
info "SDDM enabled"
warn "Reboot required"
}
preview_theme(){
local log_file="/tmp/${THEME_NAME}_$DATE.txt"
sddm-greeter-qt6 --test-mode --theme /usr/share/sddm/themes/sddm-astronaut-theme/ > $log_file 2>&1 &
greeter_pid=$!
# wait for ten seconds
for i in {1..10}; do
if ! kill -0 "$greeter_pid" 2>/dev/null; then
break
fi
sleep 1
done
if kill -0 "$greeter_pid" 2>/dev/null; then
kill "$greeter_pid"
fi
local theme="$(sed -n 's|^ConfigFile=Themes/\(.*\)\.conf|\1|p' $METADATA)"
info "Preview closed ($theme theme found)."
info "Log file: $log_file"
}
# Main menu
main() {
[[ $EUID -eq 0 ]] && { error "Don't run as root"; exit 1; }
command -v git &>/dev/null || { error "git required"; exit 1; }
check_gum
clear
while true; do
if command -v gum &>/dev/null; then
gum style --bold --padding "0 2" --border double --border-foreground 12 "π SDDM Astronaut Theme Installer"
else
echo -e "\e[36mπ SDDM Astronaut Theme Installer\e[0m"
fi
local choice=$(choose \
"π Complete Installation (recommended)" \
"π¦ Install Dependencies" \
"π₯ Clone Repository" \
"π Install Theme" \
"π§ Enable SDDM Service" \
"π¨ Select Theme Variant" \
"β¨ Preview the set theme" \
"β Exit")
case "$choice" in
"π Complete Installation (recommended)") install_deps && clone_repo && install_theme && select_theme && enable_sddm && info "Everything done!" && exit 0;;
"π¦ Install Dependencies") install_deps ;;
"π₯ Clone Repository") clone_repo ;;
"π Install Theme") install_theme ;;
"π§ Enable SDDM Service") enable_sddm ;;
"π¨ Select Theme Variant") select_theme ;;
"β¨ Preview the set theme") preview_theme;;
"β Exit") info "Goodbye!"; exit 0 ;;
esac
echo; if command -v gum &>/dev/null; then
gum input --placeholder="Press Enter to continue..."
else
echo -n "Press Enter to continue..."; read -r
fi
done
}
# trap 'echo; info "Cancelled"; exit 130' INT TERM
main "$@"