mirror of
https://github.com/Keyitdev/sddm-astronaut-theme.git
synced 2026-09-24 02:22:09 +00:00
Update: Small fixes in setup.sh script.
This commit is contained in:
@@ -5,12 +5,15 @@
|
|||||||
## Copyright (C) 2022-2025 Keyitdev
|
## Copyright (C) 2022-2025 Keyitdev
|
||||||
|
|
||||||
# Script works in Arch, Fedora, Ubuntu. Didn't tried in Void and openSUSE
|
# Script works in Arch, Fedora, Ubuntu. Didn't tried in Void and openSUSE
|
||||||
#
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
readonly THEME_REPO="https://github.com/Keyitdev/sddm-astronaut-theme.git"
|
readonly THEME_REPO="https://github.com/Keyitdev/sddm-astronaut-theme.git"
|
||||||
readonly THEME_NAME="sddm-astronaut-theme"
|
readonly THEME_NAME="sddm-astronaut-theme"
|
||||||
readonly THEMES_DIR="/usr/share/sddm/themes"
|
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=(
|
readonly -a THEMES=(
|
||||||
"astronaut" "black_hole" "cyberpunk" "hyprland_kath" "jake_the_dog"
|
"astronaut" "black_hole" "cyberpunk" "hyprland_kath" "jake_the_dog"
|
||||||
@@ -21,15 +24,15 @@ readonly -a THEMES=(
|
|||||||
# Logging with gum fallback
|
# Logging with gum fallback
|
||||||
info() {
|
info() {
|
||||||
if command -v gum &>/dev/null; then
|
if command -v gum &>/dev/null; then
|
||||||
gum style --foreground="#00ff00" "✓ $*"
|
gum style --foreground 10 "✅ $*"
|
||||||
else
|
else
|
||||||
echo -e "\e[32m✓ $*\e[0m"
|
echo -e "\e[32m✅ $*\e[0m"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
if command -v gum &>/dev/null; then
|
if command -v gum &>/dev/null; then
|
||||||
gum style --foreground="#ffaa00" "⚠ $*"
|
gum style --foreground 11 "⚠ $*"
|
||||||
else
|
else
|
||||||
echo -e "\e[33m⚠ $*\e[0m"
|
echo -e "\e[33m⚠ $*\e[0m"
|
||||||
fi
|
fi
|
||||||
@@ -37,9 +40,9 @@ warn() {
|
|||||||
|
|
||||||
error() {
|
error() {
|
||||||
if command -v gum &>/dev/null; then
|
if command -v gum &>/dev/null; then
|
||||||
gum style --foreground="#ff0000" "✗ $*" >&2
|
gum style --foreground 9 "❌ $*" >&2
|
||||||
else
|
else
|
||||||
echo -e "\e[31m✗ $*\e[0m" >&2
|
echo -e "\e[31m❌ $*\e[0m" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,13 +51,13 @@ confirm() {
|
|||||||
if command -v gum &>/dev/null; then
|
if command -v gum &>/dev/null; then
|
||||||
gum confirm "$1"
|
gum confirm "$1"
|
||||||
else
|
else
|
||||||
echo -n "$1 (y/N): "; read -r r; [[ "$r" =~ ^[Yy]$ ]]
|
echo -n "$1 (y/n): "; read -r r; [[ "$r" =~ ^[Yy]$ ]]
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
choose() {
|
choose() {
|
||||||
if command -v gum &>/dev/null; then
|
if command -v gum &>/dev/null; then
|
||||||
gum choose "$@"
|
gum choose --cursor.foreground 12 --header="" --header.foreground 12 "$@"
|
||||||
else
|
else
|
||||||
select opt in "$@"; do [[ -n "$opt" ]] && { echo "$opt"; break; }; done
|
select opt in "$@"; do [[ -n "$opt" ]] && { echo "$opt"; break; }; done
|
||||||
fi
|
fi
|
||||||
@@ -91,7 +94,7 @@ install_gum() {
|
|||||||
# Check and install gum
|
# Check and install gum
|
||||||
check_gum() {
|
check_gum() {
|
||||||
if ! command -v gum &>/dev/null; then
|
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
|
if confirm "Install gum?"; then
|
||||||
install_gum && { info "Restarting with gum..."; exec "$0" "$@"; } || warn "Using fallback UI"
|
install_gum && { info "Restarting with gum..."; exec "$0" "$@"; } || warn "Using fallback UI"
|
||||||
fi
|
fi
|
||||||
@@ -116,10 +119,9 @@ install_deps() {
|
|||||||
|
|
||||||
# Clone repository
|
# Clone repository
|
||||||
clone_repo() {
|
clone_repo() {
|
||||||
local path="$HOME/$THEME_NAME"
|
[[ -d "$PATH_TO_GIT_CLONE" ]] && mv "$PATH_TO_GIT_CLONE" "${PATH_TO_GIT_CLONE}_$DATE"
|
||||||
[[ -d "$path" ]] && rm -rf "$path"
|
spin "Cloning repository..." git clone -b master --depth 1 "$THEME_REPO" "$PATH_TO_GIT_CLONE"
|
||||||
spin "Cloning repository..." git clone -b master --depth 1 "$THEME_REPO" "$path"
|
info "Repository cloned to $PATH_TO_GIT_CLONE"
|
||||||
info "Repository cloned"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install theme
|
# Install theme
|
||||||
@@ -127,10 +129,10 @@ install_theme() {
|
|||||||
local src="$HOME/$THEME_NAME"
|
local src="$HOME/$THEME_NAME"
|
||||||
local dst="$THEMES_DIR/$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
|
# Backup and copy
|
||||||
[[ -d "$dst" ]] && sudo mv "$dst" "${dst}_$(date +%s)"
|
[[ -d "$dst" ]] && sudo mv "$dst" "${dst}_$DATE"
|
||||||
sudo mkdir -p "$dst"
|
sudo mkdir -p "$dst"
|
||||||
spin "Installing theme files..." sudo cp -r "$src"/* "$dst"/
|
spin "Installing theme files..." sudo cp -r "$src"/* "$dst"/
|
||||||
|
|
||||||
@@ -145,17 +147,16 @@ install_theme() {
|
|||||||
echo "[General]
|
echo "[General]
|
||||||
InputMethod=qtvirtualkeyboard" | sudo tee /etc/sddm.conf.d/virtualkbd.conf >/dev/null
|
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 variant
|
||||||
select_theme() {
|
select_theme() {
|
||||||
local metadata="$THEMES_DIR/$THEME_NAME/metadata.desktop"
|
[[ ! -f "$METADATA" ]] && { error "Install theme first"; return 1; }
|
||||||
[[ ! -f "$metadata" ]] && { error "Install theme first"; return 1; }
|
|
||||||
|
|
||||||
local theme=$(choose "${THEMES[@]}")
|
local theme=$(choose "${THEMES[@]}" || echo "astronaut")
|
||||||
sudo sed -i "s|^ConfigFile=.*|ConfigFile=Themes/${theme}.conf|" "$metadata"
|
sudo sed -i "s|^ConfigFile=.*|ConfigFile=Themes/${theme}.conf|" "$METADATA"
|
||||||
info "Selected: $theme"
|
info "Selected theme: $theme"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enable SDDM
|
# Enable SDDM
|
||||||
@@ -164,7 +165,32 @@ enable_sddm() {
|
|||||||
|
|
||||||
sudo systemctl disable display-manager.service 2>/dev/null || true
|
sudo systemctl disable display-manager.service 2>/dev/null || true
|
||||||
sudo systemctl enable sddm.service
|
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
|
# Main menu
|
||||||
@@ -173,41 +199,42 @@ main() {
|
|||||||
command -v git &>/dev/null || { error "git required"; exit 1; }
|
command -v git &>/dev/null || { error "git required"; exit 1; }
|
||||||
|
|
||||||
check_gum
|
check_gum
|
||||||
|
clear
|
||||||
while true; do
|
while true; do
|
||||||
echo
|
|
||||||
if command -v gum &>/dev/null; then
|
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
|
else
|
||||||
echo -e "\e[36m🚀 SDDM Astronaut Theme Installer\e[0m"
|
echo -e "\e[36m🚀 SDDM Astronaut Theme Installer\e[0m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local choice=$(choose \
|
local choice=$(choose \
|
||||||
"🚀 Complete Installation" \
|
"🚀 Complete Installation (recommended)" \
|
||||||
"📦 Install Dependencies" \
|
"📦 Install Dependencies" \
|
||||||
"📥 Clone Repository" \
|
"📥 Clone Repository" \
|
||||||
"📂 Install Theme" \
|
"📂 Install Theme" \
|
||||||
|
"🔧 Enable SDDM Service" \
|
||||||
"🎨 Select Theme Variant" \
|
"🎨 Select Theme Variant" \
|
||||||
"⚙️ Enable SDDM Service" \
|
"✨ Preview the set theme" \
|
||||||
"❌ Exit")
|
"❌ Exit")
|
||||||
|
|
||||||
case "$choice" in
|
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 ;;
|
"📦 Install Dependencies") install_deps ;;
|
||||||
"📥 Clone Repository") clone_repo ;;
|
"📥 Clone Repository") clone_repo ;;
|
||||||
"📂 Install Theme") install_theme ;;
|
"📂 Install Theme") install_theme ;;
|
||||||
|
"🔧 Enable SDDM Service") enable_sddm ;;
|
||||||
"🎨 Select Theme Variant") select_theme ;;
|
"🎨 Select Theme Variant") select_theme ;;
|
||||||
"⚙️ Enable SDDM Service") enable_sddm ;;
|
"✨ Preview the set theme") preview_theme;;
|
||||||
"❌ Exit") info "Goodbye!"; exit 0 ;;
|
"❌ Exit") info "Goodbye!"; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
echo; if command -v gum &>/dev/null; then
|
echo; if command -v gum &>/dev/null; then
|
||||||
gum input --placeholder="Press Enter to continue..."
|
gum input --placeholder="Press Enter to continue..."
|
||||||
else
|
else
|
||||||
echo -n "Press Enter..."; read -r
|
echo -n "Press Enter to continue..."; read -r
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
trap 'echo; info "Cancelled"; exit 130' INT TERM
|
# trap 'echo; info "Cancelled"; exit 130' INT TERM
|
||||||
main "$@"
|
main "$@"
|
||||||
Reference in New Issue
Block a user