Custom spinner

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

View File

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

View File

@@ -17,7 +17,7 @@ if ! command -v yay &>/dev/null; then
fi fi
echo "Installing packages" echo "Installing packages"
sudo -v sudo -v || exit 1
yay -S --noconfirm --needed - <$DOTFILES_DIR/packages.txt yay -S --noconfirm --needed - <$DOTFILES_DIR/packages.txt
echo "Changing default shell" echo "Changing default shell"