Update: updates setup.sh to download gum and simplified flow of scripit.

This commit is contained in:
dawood
2025-08-29 19:27:41 +02:00
committed by Keyitdev
parent 22bbb5ef30
commit a99918bb39
+191 -101
View File
@@ -1,123 +1,213 @@
#!/bin/bash #!/bin/bash
## Keyitdev https://github.com/Keyitdev/sddm-astronaut-theme ## SDDM Astronaut Theme Installer
## Based on original by Keyitdev https://github.com/Keyitdev/sddm-astronaut-theme
## Copyright (C) 2022-2025 Keyitdev ## Copyright (C) 2022-2025 Keyitdev
## Distributed under the GPLv3+ License https://www.gnu.org/licenses/gpl-3.0.html
red='\033[0;31m' # Script works in Arch, Fedora, Ubuntu. Didn't tried in Void and openSUSE
green='\033[0;32m' #
no_color='\033[0m' set -euo pipefail
date=$(date +%s)
path_to_git_clone="$HOME" readonly THEME_REPO="https://github.com/Keyitdev/sddm-astronaut-theme.git"
readonly THEME_NAME="sddm-astronaut-theme"
readonly THEMES_DIR="/usr/share/sddm/themes"
install_dependencies(){ readonly -a THEMES=(
if [ -x "$(command -v pacman)" ]; "astronaut" "black_hole" "cyberpunk" "hyprland_kath" "jake_the_dog"
then "japanese_aesthetic" "pixel_sakura" "pixel_sakura_static"
echo -e "${green}[*] Installing packages using pacman.${no_color}" "post-apocalyptic_hacker" "purple_leaves"
sudo pacman --noconfirm --needed -S sddm qt6-svg qt6-virtualkeyboard qt6-multimedia-ffmpeg )
elif [ -x "$(command -v xbps-install)" ];
then # Logging with gum fallback
echo -e "${green}[*] Installing packages using xbps-install.${no_color}" info() {
sudo xbps-install sddm qt6-svg qt6-virtualkeyboard qt6-multimedia if command -v gum &>/dev/null; then
elif [ -x "$(command -v dnf)" ]; gum style --foreground="#00ff00" "$*"
then
echo -e "${green}[*] Installing packages using dnf.${no_color}"
sudo dnf install sddm qt6-qtsvg qt6-qtvirtualkeyboard qt6-qtmultimedia
elif [ -x "$(command -v zypper)" ];
then
echo -e "${green}[*] Installing packages using zypper.${no_color}"
sudo zypper install sddm-qt6 libQt6Svg6 qt6-virtualkeyboard qt6-virtualkeyboard-imports qt6-multimedia qt6-multimedia-imports
else else
echo -e "${red}[*] FAILED TO INSTALL PACKAGE: Package manager not found. You must manually install dependencies.">&2; echo -e "\e[32m✓ $*\e[0m"
fi fi
} }
git_clone(){ warn() {
umask 022 if command -v gum &>/dev/null; then
echo -e "${green}[*] Cloning theme to $path_to_git_clone.${no_color}" gum style --foreground="#ffaa00" "$*"
[ -d "$path_to_git_clone"/sddm-astronaut-theme ] && sudo mv "$path_to_git_clone"/sddm-astronaut-theme "$path_to_git_clone"/sddm-astronaut-theme_$date && echo -e "${green}[*] Old configs detected in $path_to_git_clone, backing up.${no_color}" else
git clone -b master --depth 1 https://github.com/keyitdev/sddm-astronaut-theme.git "$path_to_git_clone"/sddm-astronaut-theme echo -e "\e[33m⚠ $*\e[0m"
fi
} }
copy_files(){ error() {
umask 022 if command -v gum &>/dev/null; then
echo -e "${green}[*] Coping theme from $path_to_git_clone to /usr/share/sddm/themes/.${no_color}" gum style --foreground="#ff0000" "$*" >&2
[ -d /usr/share/sddm/themes/sddm-astronaut-theme ] && sudo mv /usr/share/sddm/themes/sddm-astronaut-theme /usr/share/sddm/themes/sddm-astronaut-theme_$date && echo -e "${green}[*] Old configs detected in /usr/share/sddm/themes/sddm-astronaut-theme, backing up.${no_color}" else
sudo mkdir -p /usr/share/sddm/themes/sddm-astronaut-theme echo -e "\e[31m✗ $*\e[0m" >&2
sudo cp -r "$path_to_git_clone"/sddm-astronaut-theme/* /usr/share/sddm/themes/sddm-astronaut-theme fi
sudo cp -r /usr/share/sddm/themes/sddm-astronaut-theme/Fonts/* /usr/share/fonts/ }
echo -e "${green}[*] Setting up theme.${no_color}"
# 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 "$@"
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 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) 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 not found - provides better UI experience"
if confirm "Install gum?"; then
install_gum && { info "Restarting with gum..."; exec "$0" "$@"; } || warn "Using fallback UI"
fi
fi
}
# Install dependencies
install_deps() {
local mgr=$(for m in pacman xbps 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) 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() {
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"
}
# 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 +%s)"
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] echo "[Theme]
Current=sddm-astronaut-theme" | sudo tee /etc/sddm.conf Current=$THEME_NAME" | sudo tee /etc/sddm.conf >/dev/null
sudo mkdir -p /etc/sddm.conf.d sudo mkdir -p /etc/sddm.conf.d
echo "[General] echo "[General]
InputMethod=qtvirtualkeyboard" | sudo tee /etc/sddm.conf.d/virtualkbd.conf InputMethod=qtvirtualkeyboard" | sudo tee /etc/sddm.conf.d/virtualkbd.conf >/dev/null
info "Theme installed and configured"
} }
select_theme(){ # Select theme variant
path_to_metadata="/usr/share/sddm/themes/sddm-astronaut-theme/metadata.desktop" select_theme() {
text="ConfigFile=Themes/" local metadata="$THEMES_DIR/$THEME_NAME/metadata.desktop"
[[ ! -f "$metadata" ]] && { error "Install theme first"; return 1; }
line=$(grep $text "$path_to_metadata") local theme=$(choose "${THEMES[@]}")
sudo sed -i "s|^ConfigFile=.*|ConfigFile=Themes/${theme}.conf|" "$metadata"
themes="astronaut black_hole cyberpunk hyprland_kath jake_the_dog japanese_aesthetic pixel_sakura pixel_sakura_static post-apocalyptic_hacker purple_leaves" info "Selected: $theme"
echo -e "${green}[*] Select theme (enter number e.g. astronaut - 1).${no_color}"
echo -e "${green}[*] 0. Other (choose if you created your own theme)."
echo -e "${green}[*] 1. Astronaut 2. Black hole${no_color}"
echo -e "${green}[*] 3. Cyberpunk 4. Hyprland Kath (animated)${no_color}"
echo -e "${green}[*] 5. Jake the dog (animated) 6. Japanese aesthetic${no_color}"
echo -e "${green}[*] 7. Pixel sakura (animated) 8. Pixel sakura (static)${no_color}"
echo -e "${green}[*] 9. Post-apocalyptic hacker 10. Purple leaves${no_color}"
read -p "[*] Your choice: " new_number
if [ "$new_number" -eq 0 ] 2>/dev/null;then
echo -e "${green}[*] Enter name of the config file (without .conf).${no_color}"
read -p "[*] Theme name: " answer
selected_theme="$answer"
elif [ "$new_number" -ge 1 ] 2>/dev/null && [ "$new_number" -le 10 ] 2>/dev/null; then
set -- $themes
selected_theme=$(echo "$@" | cut -d ' ' -f $(("new_number")))
echo -e "${green}[*] You selected: $selected_theme ${no_color}"
else
echo -e "${red}[*] Error: invalid number or input.${no_color}"
exit
fi
modified_line="$text$selected_theme.conf"
sudo sed -i "s|^$text.*|$modified_line|" $path_to_metadata
echo -e "${green}[*] Changed: $line -> $modified_line${no_color}"
} }
enable_sddm(){ # Enable SDDM
systemctl disable display-manager.service enable_sddm() {
systemctl enable sddm.service 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 - reboot required"
} }
while true; do # Main menu
clear main() {
echo -e "${green}sddm-astronaut-theme made by Keyitdev${no_color}" [[ $EUID -eq 0 ]] && { error "Don't run as root"; exit 1; }
echo -e "${green}[*] Choose option.${no_color}" command -v git &>/dev/null || { error "git required"; exit 1; }
echo -e "1. All of the below."
echo -e "2. Install dependencies with package manager." check_gum
echo -e "3. Clone theme from github.com to $path_to_git_clone."
echo -e "4. Copy theme from $path_to_git_clone to /usr/share/sddm/themes/." while true; do
echo -e "5. Select theme (/usr/share/sddm/themes/)." echo
echo -e "6. Preview the set theme (/usr/share/sddm/themes/)." if command -v gum &>/dev/null; then
echo -e "7. Disable other display managers and enable SDDM (systemd)." gum style --foreground="#00ffff" "🚀 SDDM Astronaut Theme Installer"
echo -e "8. Exit." else
read -p "[*] Your choice: " x echo -e "\e[36m🚀 SDDM Astronaut Theme Installer\e[0m"
case $x in fi
[1]* ) install_dependencies; git_clone; copy_files; select_theme; enable_sddm; exit;;
[2]* ) install_dependencies; exit;; local choice=$(choose \
[3]* ) git_clone; exit;; "🚀 Complete Installation" \
[4]* ) copy_files; exit;; "📦 Install Dependencies" \
[5]* ) select_theme; exit;; "📥 Clone Repository" \
[6]* ) sddm-greeter-qt6 --test-mode --theme /usr/share/sddm/themes/sddm-astronaut-theme/; exit;; "📂 Install Theme" \
[7]* ) enable_sddm; exit;; "🎨 Select Theme Variant" \
[8]* ) exit;; "⚙️ Enable SDDM Service" \
* ) echo -e "${red}[*] Error: invalid number or input.${no_color}";; "❌ Exit")
esac
done case "$choice" in
"🚀 Complete Installation") install_deps && clone_repo && install_theme && select_theme && enable_sddm ;;
"📦 Install Dependencies") install_deps ;;
"📥 Clone Repository") clone_repo ;;
"📂 Install Theme") install_theme ;;
"🎨 Select Theme Variant") select_theme ;;
"⚙️ Enable SDDM Service") enable_sddm ;;
"❌ 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
fi
done
}
trap 'echo; info "Cancelled"; exit 130' INT TERM
main "$@"