Update: Small fixes in setup.sh script.

This commit is contained in:
Keyitdev
2025-08-30 16:35:20 +02:00
parent a99918bb39
commit f759e87431
+60 -33
View File
@@ -5,12 +5,15 @@
## 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"
@@ -21,15 +24,15 @@ readonly -a THEMES=(
# Logging with gum fallback
info() {
if command -v gum &>/dev/null; then
gum style --foreground="#00ff00" " $*"
gum style --foreground 10 " $*"
else
echo -e "\e[32m $*\e[0m"
echo -e "\e[32m $*\e[0m"
fi
}
warn() {
if command -v gum &>/dev/null; then
gum style --foreground="#ffaa00" "$*"
gum style --foreground 11 " $*"
else
echo -e "\e[33m⚠ $*\e[0m"
fi
@@ -37,9 +40,9 @@ warn() {
error() {
if command -v gum &>/dev/null; then
gum style --foreground="#ff0000" " $*" >&2
gum style --foreground 9 " $*" >&2
else
echo -e "\e[31m $*\e[0m" >&2
echo -e "\e[31m $*\e[0m" >&2
fi
}
@@ -48,13 +51,13 @@ confirm() {
if command -v gum &>/dev/null; then
gum confirm "$1"
else
echo -n "$1 (y/N): "; read -r r; [[ "$r" =~ ^[Yy]$ ]]
echo -n "$1 (y/n): "; read -r r; [[ "$r" =~ ^[Yy]$ ]]
fi
}
choose() {
if command -v gum &>/dev/null; then
gum choose "$@"
gum choose --cursor.foreground 12 --header="" --header.foreground 12 "$@"
else
select opt in "$@"; do [[ -n "$opt" ]] && { echo "$opt"; break; }; done
fi
@@ -91,7 +94,7 @@ install_gum() {
# Check and install gum
check_gum() {
if ! command -v gum &>/dev/null; then
warn "gum not found - provides better UI experience"
warn "Gum was not found - provides better UI experience"
if confirm "Install gum?"; then
install_gum && { info "Restarting with gum..."; exec "$0" "$@"; } || warn "Using fallback UI"
fi
@@ -116,10 +119,9 @@ install_deps() {
# Clone repository
clone_repo() {
local path="$HOME/$THEME_NAME"
[[ -d "$path" ]] && rm -rf "$path"
spin "Cloning repository..." git clone -b master --depth 1 "$THEME_REPO" "$path"
info "Repository cloned"
[[ -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
@@ -127,10 +129,10 @@ install_theme() {
local src="$HOME/$THEME_NAME"
local dst="$THEMES_DIR/$THEME_NAME"
[[ ! -d "$src" ]] && { error "Clone repository first"; return 1; }
[[ ! -d "$src" ]] && { error "Clone repository first"; return 1;}
# Backup and copy
[[ -d "$dst" ]] && sudo mv "$dst" "${dst}_$(date +%s)"
[[ -d "$dst" ]] && sudo mv "$dst" "${dst}_$DATE"
sudo mkdir -p "$dst"
spin "Installing theme files..." sudo cp -r "$src"/* "$dst"/
@@ -145,17 +147,16 @@ install_theme() {
echo "[General]
InputMethod=qtvirtualkeyboard" | sudo tee /etc/sddm.conf.d/virtualkbd.conf >/dev/null
info "Theme installed and configured"
info "Theme installed"
}
# Select theme variant
select_theme() {
local metadata="$THEMES_DIR/$THEME_NAME/metadata.desktop"
[[ ! -f "$metadata" ]] && { error "Install theme first"; return 1; }
local theme=$(choose "${THEMES[@]}")
sudo sed -i "s|^ConfigFile=.*|ConfigFile=Themes/${theme}.conf|" "$metadata"
info "Selected: $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
@@ -164,7 +165,32 @@ enable_sddm() {
sudo systemctl disable display-manager.service 2>/dev/null || true
sudo systemctl enable sddm.service
info "SDDM enabled - reboot required"
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
@@ -173,41 +199,42 @@ main() {
command -v git &>/dev/null || { error "git required"; exit 1; }
check_gum
clear
while true; do
echo
if command -v gum &>/dev/null; then
gum style --foreground="#00ffff" "🚀 SDDM Astronaut Theme Installer"
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" \
"🚀 Complete Installation (recommended)" \
"📦 Install Dependencies" \
"📥 Clone Repository" \
"📂 Install Theme" \
"🔧 Enable SDDM Service" \
"🎨 Select Theme Variant" \
"⚙️ Enable SDDM Service" \
"✨ Preview the set theme" \
"❌ Exit")
case "$choice" in
"🚀 Complete Installation") install_deps && clone_repo && install_theme && select_theme && enable_sddm ;;
"🚀 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 ;;
"⚙️ Enable SDDM Service") enable_sddm ;;
"✨ 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..."; read -r
echo -n "Press Enter to continue..."; read -r
fi
done
}
trap 'echo; info "Cancelled"; exit 130' INT TERM
main "$@"
# trap 'echo; info "Cancelled"; exit 130' INT TERM
main "$@"