-
-
Notifications
You must be signed in to change notification settings - Fork 166
Description
KDE-Desktop will need to be installed
#!/bin/bash
SDDM Astronaut Theme Installer - Ubuntu Edition
Based on original by Keyitdev https://github.com/Keyitdev/sddm-astronaut-theme
Copyright (C) 2022-2025 Keyitdev
Ubuntu port and optimizations
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
}
Check Ubuntu version and compatibility
check_ubuntu() {
if [[ ! -f /etc/os-release ]]; then
error "Cannot detect OS version"
exit 1
fi
source /etc/os-release
if [[ "$ID" != "ubuntu" ]]; then
warn "This script is optimized for Ubuntu, but detected: $ID"
if ! confirm "Continue anyway?"; then
exit 1
fi
fi
local version_id=${VERSION_ID%.*}
if [[ $version_id -lt 20 ]]; then
error "Ubuntu 20.04 LTS or newer required (detected: $VERSION_ID)"
exit 1
fi
info "Ubuntu $VERSION_ID detected"
}
Install gum for better UI
install_gum() {
info "Installing gum for better user interface..."
# Add Charm repository
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
info "Gum installed successfully"
}
Check and install gum
check_gum() {
if ! command -v gum &>/dev/null; then
warn "Gum not found - it provides a much better user experience"
if confirm "Install gum for enhanced UI?"; then
if install_gum; then
info "Restarting with enhanced UI..."
exec "$0" "$@"
else
warn "Failed to install gum, using fallback UI"
fi
fi
fi
}
Install dependencies for Ubuntu
install_deps() {
info "Installing SDDM and Qt6 dependencies for Ubuntu..."
# Update package list
spin "Updating package list..." sudo apt update
# Install required packages
local packages=(
"sddm"
"qt6-base-dev"
"qt6-declarative-dev"
"qml6-module-qtquick"
"qml6-module-qtquick-controls"
"qml6-module-qtquick-layouts"
"qml6-module-qt-labs-platform"
"qml6-module-qtquick-virtualkeyboard"
"qt6-multimedia-dev"
"libqt6svg6-dev"
"git"
)
spin "Installing SDDM and Qt6 packages..." sudo apt install -y "${packages[@]}"
info "Dependencies installed successfully"
# Check if we're in a desktop environment that might conflict
if [[ -n "${DESKTOP_SESSION:-}" ]]; then
warn "Desktop session detected: $DESKTOP_SESSION"
warn "SDDM will replace your current display manager"
fi
}
Clone repository
clone_repo() {
if [[ -d "$PATH_TO_GIT_CLONE" ]]; then
warn "Existing installation found"
mv "$PATH_TO_GIT_CLONE" "${PATH_TO_GIT_CLONE}backup$DATE"
info "Previous installation backed up"
fi
spin "Cloning theme 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="https://github.com/$HOME/$THEME_NAME"
local dst="$THEMES_DIR/$THEME_NAME"
if [[ ! -d "$src" ]]; then
error "Theme repository not found. Please clone repository first."
return 1
fi
# Backup existing theme
if [[ -d "$dst" ]]; then
warn "Existing theme installation found"
sudo mv "$dst" "${dst}_backup_$DATE"
info "Previous theme backed up"
fi
# Create theme directory and copy files
sudo mkdir -p "$dst"
spin "Installing theme files..." sudo cp -r "$src"/* "$dst"/
# Install fonts if available
if [[ -d "$dst/Fonts" ]]; then
spin "Installing fonts..." sudo cp -r "$dst/Fonts"/* /usr/share/fonts/
sudo fc-cache -fv >/dev/null 2>&1
info "Fonts installed and cache updated"
fi
# Configure SDDM
sudo mkdir -p /etc/sddm.conf.d
# Main SDDM configuration
if [[ ! -f /etc/sddm.conf ]]; then
echo "[Theme]
Current=$THEME_NAME" | sudo tee /etc/sddm.conf >/dev/null
else
# Update existing config
if grep -q "^[Theme]" /etc/sddm.conf; then
sudo sed -i "s|^Current=.*|Current=$THEME_NAME|" /etc/sddm.conf
else
echo "[Theme]
Current=$THEME_NAME" | sudo tee -a /etc/sddm.conf >/dev/null
fi
fi
# Virtual keyboard configuration
echo "[General]
InputMethod=qtvirtualkeyboard
[Wayland]
SessionDir=/usr/share/wayland-sessions
[X11]
SessionDir=/usr/share/xsessions" | sudo tee /etc/sddm.conf.d/virtualkbd.conf >/dev/null
info "Theme installed and configured"
}
Select theme variant
select_theme() {
if [[ ! -f "$METADATA" ]]; then
error "Theme not installed. Please install theme first."
return 1
fi
info "Available theme variants:"
local theme
if command -v gum &>/dev/null; then
theme=$(gum choose --header="Select a theme variant:" "${THEMES[@]}")
else
echo "Please select a theme variant:"
select theme in "${THEMES[@]}"; do
[[ -n "$theme" ]] && break
done
fi
[[ -z "$theme" ]] && theme="astronaut"
sudo sed -i "s|^ConfigFile=.*|ConfigFile=Themes/${theme}.conf|" "$METADATA"
info "Selected theme variant: $theme"
}
Enable SDDM service
enable_sddm() {
if ! command -v systemctl &>/dev/null; then
error "systemctl not found - cannot manage services"
return 1
fi
# Disable other display managers
local current_dm
if systemctl is-enabled gdm3 &>/dev/null; then
current_dm="gdm3"
elif systemctl is-enabled lightdm &>/dev/null; then
current_dm="lightdm"
elif systemctl is-enabled kdm &>/dev/null; then
current_dm="kdm"
fi
if [[ -n "${current_dm:-}" ]]; then
warn "Current display manager: $current_dm"
if confirm "Disable $current_dm and enable SDDM?"; then
sudo systemctl disable "$current_dm"
info "Disabled $current_dm"
fi
fi
sudo systemctl disable display-manager.service 2>/dev/null || true
sudo systemctl enable sddm.service
info "SDDM service enabled"
warn "Reboot required to see the new login screen"
}
Preview theme
preview_theme() {
if [[ ! -f "$METADATA" ]]; then
error "Theme not installed. Please install theme first."
return 1
fi
if ! command -v sddm-greeter-qt6 &>/dev/null; then
error "sddm-greeter-qt6 not found. Please install SDDM first."
return 1
fi
local log_file="/tmp/${THEME_NAME}_preview_$DATE.log"
info "Starting theme preview (will close automatically in 10 seconds)..."
info "Use Ctrl+C to close preview manually"
# Start preview in background
sddm-greeter-qt6 --test-mode --theme "$THEMES_DIR/$THEME_NAME/" > "$log_file" 2>&1 &
local greeter_pid=$!
# Wait for 10 seconds or until process dies
for i in {1..10}; do
if ! kill -0 "$greeter_pid" 2>/dev/null; then
break
fi
sleep 1
if command -v gum &>/dev/null; then
echo -ne "\r$(gum style --foreground 12 "Preview running... ${i}/10 seconds")"
else
echo -ne "\rPreview running... ${i}/10 seconds"
fi
done
# Kill preview if still running
if kill -0 "$greeter_pid" 2>/dev/null; then
kill "$greeter_pid" 2>/dev/null || true
fi
echo # New line after progress indicator
# Show current theme
local current_theme
current_theme=$(sed -n 's|^ConfigFile=Themes/\(.*\)\.conf|\1|p' "$METADATA" 2>/dev/null || echo "unknown")
info "Preview closed (current theme: $current_theme)"
info "Preview log saved to: $log_file"
}
Uninstall theme
uninstall_theme() {
warn "This will remove the SDDM Astronaut theme"
if ! confirm "Are you sure you want to uninstall?"; then
return 0
fi
# Remove theme directory
if [[ -d "$THEMES_DIR/$THEME_NAME" ]]; then
sudo rm -rf "$THEMES_DIR/$THEME_NAME"
info "Theme files removed"
fi
# Reset SDDM config
if [[ -f /etc/sddm.conf ]]; then
sudo sed -i "s|^Current=$THEME_NAME|Current=|" /etc/sddm.conf
info "SDDM configuration reset"
fi
# Remove local clone
if [[ -d "$PATH_TO_GIT_CLONE" ]]; then
rm -rf "$PATH_TO_GIT_CLONE"
info "Local repository removed"
fi
info "Theme uninstalled successfully"
}
Main menu
main() {
# Security check
if [[ $EUID -eq 0 ]]; then
error "Don't run this script as root!"
exit 1
fi
# Check dependencies
if ! command -v git &>/dev/null; then
error "git is required but not installed"
error "Install with: sudo apt install git"
exit 1
fi
check_ubuntu
check_gum
while true; do
clear
if command -v gum &>/dev/null; then
gum style --bold --padding "1 2" --border double --border-foreground 12 --align center \
"🚀 SDDM Astronaut Theme Installer" \
"Ubuntu Edition" \
"" \
"Choose an option below:"
else
echo -e "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m"
echo -e "\e[36m🚀 SDDM Astronaut Theme Installer - Ubuntu Edition\e[0m"
echo -e "\e[36m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\e[0m"
echo
fi
local choice
choice=$(choose \
"🚀 Complete Installation (Recommended)" \
"📦 Install Dependencies Only" \
"📥 Clone Theme Repository" \
"🎨 Install Theme Files" \
"🔧 Enable SDDM Service" \
"✨ Select Theme Variant" \
"👀 Preview Current Theme" \
"🗑️ Uninstall Theme" \
"ℹ️ System Information" \
"❌ Exit")
case "$choice" in
"🚀 Complete Installation (Recommended)")
install_deps && clone_repo && install_theme && select_theme && enable_sddm
info "🎉 Complete installation finished!"
info "💡 Reboot your system to see the new login screen"
exit 0
;;
"📦 Install Dependencies Only") install_deps ;;
"📥 Clone Theme Repository") clone_repo ;;
"🎨 Install Theme Files") install_theme ;;
"🔧 Enable SDDM Service") enable_sddm ;;
"✨ Select Theme Variant") select_theme ;;
"👀 Preview Current Theme") preview_theme ;;
"🗑️ Uninstall Theme") uninstall_theme ;;
"ℹ️ System Information")
echo
info "System Information:"
echo " OS: $(lsb_release -d | cut -f2)"
echo " Kernel: $(uname -r)"
echo " Desktop: ${DESKTOP_SESSION:-Unknown}"
echo " Display Server: ${XDG_SESSION_TYPE:-Unknown}"
echo " SDDM Installed: $(command -v sddm &>/dev/null && echo "Yes" || echo "No")"
echo " Theme Installed: $([[ -d "$THEMES_DIR/$THEME_NAME" ]] && echo "Yes" || echo "No")"
;;
"❌ Exit")
info "👋 Thanks for using SDDM Astronaut Theme!"
exit 0
;;
esac
echo
if command -v gum &>/dev/null; then
gum input --placeholder="Press Enter to continue..." >/dev/null
else
echo -n "Press Enter to continue..."
read -r
fi
done
}
Handle interruption gracefully
trap 'echo; warn "Installation cancelled by user"; exit 130' INT TERM
Start the installer
main "$@"