Files
LinaraOS/xfce/root-overlay/etc/skel/.config/hypr/LibreOS/fish/menu.sh
2026-06-23 23:58:58 -05:00

194 lines
5.8 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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 Archbased 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<pad;i++)); do echo; done
}
# ------------------------------------------------------------
# 3⃣ Simple banner “SCE OS”
# ------------------------------------------------------------
BANNER="SCE OS"
# ------------------------------------------------------------
# 4⃣ Pause helper
# ------------------------------------------------------------
pause() {
read -rp $'\nPress ENTER to return to the previous menu…' </dev/tty
}
# ------------------------------------------------------------
# 5⃣ Render a centered menu (banner + choices)
# ------------------------------------------------------------
render_menu() {
local -n items=$1 # namereference to array of choices
local title="${2:-}" # optional title (already centred)
# total lines = banner + optional title + blank line + number of items
local total=$(( 1 + ( [[ -n $title ]] && echo 1 || echo 0 ) + 1 + ${#items[@]} ))
clear
center_vertically "$total"
echo "$(center_horiz "$BANNER")"
echo # blank line after banner
[[ -n $title ]] && echo "$(center_horiz "$title")"
# write centred choices to a temp file for gum
local tmp; tmp=$(mktemp)
for choice in "${items[@]}"; do
echo "$(center_horiz "$choice")" >>"$tmp"
done
gum choose --cursor.foreground 212 --selected.foreground 212 <"$tmp"
rm "$tmp"
}
# ------------------------------------------------------------
# 6⃣ Submenus
# ------------------------------------------------------------
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"
"Fullsystem 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
;;
*"Fullsystem 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 "Goodbye!"; exit 0 ;;
esac
done
}
main_menu