Custom spinner

This commit is contained in:
2026-01-09 01:10:49 +01:00
parent dd915fa586
commit 62d8713835
2 changed files with 62 additions and 35 deletions

View File

@@ -2,14 +2,41 @@
set -e
sudo -v || exit 1
###################
## Spinner stuff ##
###################
# keep sudo alive until script exits
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
done 2>/dev/null &
execute_with_spinner() {
local title="$1"
shift
spinner='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
local i=0
draw_status() {
tput sc
tput cup $(($(tput lines) - 1)) 0
printf "%s %s" "${spinner:i++%${#spinner}:1}" "$title"
tput el
tput rc
}
while sleep 0.05; do
draw_status
done &
SPIN_PID=$!
"$@"
local status=$?
kill "$SPIN_PID"
wait "$SPIN_PID" 2>/dev/null || true
echo
return $status
}
#########################
## gum style variables ##
@@ -18,7 +45,7 @@ done 2>/dev/null &
GUM_SPIN_SPINNER="minidot"
GUM_SPIN_SHOW_OUTPUT="true"
sudo -v
sudo -v || exit 1
####################
## Installing gum ##
@@ -26,7 +53,7 @@ sudo -v
if ! command -v gum &>/dev/null; then
echo "Installing gum"
sudo pacman -S --needed --noconfirm gum
execute_with_spinner "Installing gum" sudo pacman -S --needed --noconfirm gum
fi
###################################
@@ -34,19 +61,19 @@ fi
###################################
if ! command -v yay &>/dev/null; then
sudo -v
sudo -v || exit 1
# gum spin --title "Installing yay dependencies" -- \
sudo pacman -S base-devel git --needed --noconfirm
execute_with_spinner "Installing yay dependencies" sudo pacman -S base-devel git --needed --noconfirm
TEMP_DIR=$(mktemp -d)
# gum spin --title "Cloning yay-bin from AUR" -- \
git clone https://aur.archlinux.org/yay-bin.git $TEMP_DIR/yay
execute_with_spinner "Cloning yay-bin from AUR" git clone https://aur.archlinux.org/yay-bin.git $TEMP_DIR/yay
cd $TEMP_DIR/yay
sudo -v
sudo -v || exit 1
# gum spin --title "Installing yay" -- \
makepkg -si --noconfirm
execute_with_spinner "Installing yay" makepkg -si --noconfirm
fi
#############################
@@ -86,9 +113,9 @@ mapfile -t extratools < <(
## Installing stow ##
#####################
sudo -v
sudo -v || exit 1
# gum spin --title "Installing GNU Stow" -- \
yay -S --needed --noconfirm stow
execute_with_spinner "Installing GNU Stow" yay -S --needed --noconfirm stow
######################
## Applying configs ##
@@ -97,9 +124,9 @@ yay -S --needed --noconfirm stow
for choice in "${desktop[@]}"; do
case "$choice" in
"Niri")
sudo -v
sudo -v || exit 1
# gum spin --title "Installing niri alongside required packages" -- \
yay -S --needed --noconfirm \
execute_with_spinner "Installing niri and required packages" yay -S --needed --noconfirm \
niri \
ly \
nautilus \
@@ -121,9 +148,9 @@ for choice in "${desktop[@]}"; do
;;
"KDE Plasma")
sudo -v
sudo -v || exit 1
# gum spin --title "Installing KDE Plasma" -- \
pacman -S --needed --noconfirm plasma kde-applications
execute_with_spinner "Installing KDE Plasma" pacman -S --needed --noconfirm plasma kde-applications
sudo systemctl enable sddm
;;
esac
@@ -132,9 +159,9 @@ done
for choice in "${tools[@]}"; do
case "$choice" in
"Terminal")
sudo -v
sudo -v || exit 1
# gum spin --title "Installing Terminal packages..." -- \
yay -S --needed --noconfirm \
"Installing Terminal packages" yay -S --needed --noconfirm \
fastfetch \
hyfetch \
neovim \
@@ -149,21 +176,21 @@ for choice in "${tools[@]}"; do
reflector
stow fastfetch hyfetch nvim zsh --override
# gum spin --title "Updating Tealdeer database" -- \
tldr --update
execute_with_spinner "Updating Tealdeer database" tldr --update
;;
"Terminal Emulator")
sudo -v
sudo -v || exit 1
# gum spin --title "Installing Terminal Emulator..." -- \
yay -S --needed --noconfirm \
execute_with_spinner "Installing Terminal Emulator" yay -S --needed --noconfirm \
ghostty
stow ghostty --override
;;
"Gaming")
sudo -v
sudo -v || exit 1
# gum spin --title "Installing Gaming Packages..." -- \
yay -S --needed --noconfirm \
execute_with_spinner "Installing Gaming packages" yay -S --needed --noconfirm \
mangohud \
gamemode \
steam \
@@ -172,24 +199,24 @@ for choice in "${tools[@]}"; do
arrpc
stow mangohud --override
sudo -v
sudo -v || exit 1
# gum spin --spinner minidot --title "Applying arrpy systemd fix..." -- \
sudo cp /usr/lib/systemd/user/arrpc.service /etc/systemd/system/arrpc.service &&
sudo systemctl enable arrpc --now
;;
"VR Gaming")
sudo -v
sudo -v || exit 1
# gum spin --title "Installing VR Gaming Packages..." -- \
yay -S --needed --noconfirm \
execute_with_spinner "Installing VR Gaming packages" yay -S --needed --noconfirm \
alvr-launcher-bin \
wlx-overlay-s-bin
;;
"Hamr Sticker Picker")
sudo -v
sudo -v || exit 1
# gum spin --title "Installing hamr..." -- \
yay -S --needed --noconfirm \
execute_with_spinner "Installing hamr" yay -S --needed --noconfirm \
hamr
stow hamr-sticker-picker --override
@@ -230,6 +257,6 @@ extpkgstr=$(
echo "${extrapkgs[*]}"
)
sudo -v
sudo -v || exit 1
# gum spin --title "Installing extra packages" -- \
yay -S --needed --noconfirm "$extpkgstr"
execute_with_spinner "Installing extra packages" yay -S --needed --noconfirm "$extpkgstr"