#!/usr/bin/env bash # ------------------------------------------------------------ # SCE OS – centered TUI (simple “SCE OS” banner) using gum # ------------------------------------------------------------ set -euo pipefail # ------------------------------------------------------------ # 1️⃣ Install gum (pacman) if missing # ------------------------------------------------------------ install_gum() { if ! command -v pacman &>/dev/null; then echo "Error: pacman not found – this script works only on Arch‑based systems." exit 1 fi if command -v gum &>/dev/null; then echo "gum already installed (version: $(gum --version))." return fi echo "Updating package database..." sudo pacman -Sy --noconfirm echo "Installing gum..." sudo pacman -S --noconfirm gum echo "gum installed successfully (version: $(gum --version))." } install_gum # ------------------------------------------------------------ # 2️⃣ Helpers for centering # ------------------------------------------------------------ term_width() { tput cols; } term_height() { tput lines; } center_horiz() { local text="$1" local width=$(term_width) local pad=$(( (width - ${#text}) / 2 )) printf "%*s%s" "$pad" "" "$text" } center_vertically() { local lines=$1 local height=$(term_height) local pad=$(( (height - lines) / 2 )) for ((i=0;i>"$tmp" done gum choose --cursor.foreground 212 --selected.foreground 212 <"$tmp" rm "$tmp" } # ------------------------------------------------------------ # 6️⃣ Sub‑menus # ------------------------------------------------------------ terminal_menu() { local opts=( "Open new terminal session" "Back to main menu" ) while true; do sel=$(render_menu opts "Terminal") case "$sel" in *"Open new terminal session"*) echo "Launching a new terminal…" gnome-terminal & pause ;; *"Back to main menu"*) break ;; esac done } system_menu() { local opts=( "Get repository update" "Full‑system update and upgrade" "Back to main menu" ) while true; do sel=$(render_menu opts "System") case "$sel" in *"Get repository update"*) echo "Running repository update (git pull …)" (cd ~/myrepo && git pull) # adjust as needed pause ;; *"Full‑system update and upgrade"*) echo "Performing full system upgrade…" sudo pacman -Syu --noconfirm pause ;; *"Back to main menu"*) break ;; esac done } software_menu() { local opts=( "Install / update Blender (~/Programs/Blender-version)" "Install / update Nekoray (~/Programs/nekoray.appimage)" "Back to main menu" ) while true; do sel=$(render_menu opts "Software") case "$sel" in *"Blender"* ) echo "Downloading latest Blender into ~/Programs/Blender-version …" mkdir -p "$HOME/Programs/Blender-version" wget -qO- "https://download.blender.org/release/Blender3.6/blender-3.6.0-linux-x64.tar.xz" | tar -xJ -C "$HOME/Programs/Blender-version" --strip-components=1 pause ;; *"Nekoray"* ) echo "Fetching latest Nekoray AppImage into ~/Programs …" mkdir -p "$HOME/Programs" wget -O "$HOME/Programs/nekoray.appimage" \ "https://github.com/nekoray/nekoray/releases/download/v2.16.0/nekoray-2.16.0-x86_64.AppImage" chmod +x "$HOME/Programs/nekoray.appimage" pause ;; *"Back to main menu"* ) break ;; esac done } # ------------------------------------------------------------ # 7️⃣ Main menu (centered) # ------------------------------------------------------------ main_menu() { local opts=( "Terminal" "System" "Software" "Quit" ) while true; do choice=$(render_menu opts "SCE OS") case "$choice" in *"Terminal"*) terminal_menu ;; *"System"*) system_menu ;; *"Software"*) software_menu ;; *"Quit"*) clear; echo "Good‑bye!"; exit 0 ;; esac done } main_menu