More improvements to progress bars. Hopefully fixed a bug that was causing games to install twice.

This commit is contained in:
Storm Dragon
2025-08-06 00:39:17 -04:00
parent 6351d88676
commit 27f9e973a3
2 changed files with 37 additions and 43 deletions

View File

@@ -226,40 +226,30 @@ agm_progressbox() {
local text="$2" local text="$2"
if [[ "$dialogType" == "yad" ]]; then if [[ "$dialogType" == "yad" ]]; then
# Use a text-info dialog with improved real-time output display # Use accessible form approach without temp files
# Force line buffering and use named pipe for better responsiveness # Process command output first to get summary info
local tmpPipe local lineCount=0
tmpPipe=$(mktemp -u) local lastLine="Starting..."
mkfifo "$tmpPipe" local allOutput=""
# Start yad in background reading from the pipe # Collect output while command runs
yad --text-info \ while IFS= read -r line; do
((lineCount++))
lastLine="$line"
allOutput="${allOutput}${line}\n"
done < <(stdbuf -oL cat)
# Show completion dialog with accessible summary
yad --form \
--title="$title" \ --title="$title" \
--text="$text" \ --field="$text - Completed:LBL" \
--width=600 \ --field="Total steps: $lineCount:LBL" \
--height=400 \ --field="Last action::LBL" \
--timeout=1 \ --field="$lastLine:RO" \
--timeout-indicator=bottom \ --selectable-labels \
--button="Close:0" \ --button="OK:0" \
--tail \ --width=500 \
--auto-scroll \ --height=200
--filename="$tmpPipe" &
local yadPid=$!
# Process input and write to pipe with unbuffered output
{
stdbuf -oL cat
echo "=== Operation completed ==="
} > "$tmpPipe" &
local catPid=$!
# Wait for either process to finish
wait $catPid 2>/dev/null
# Clean up
sleep 1 # Brief pause to ensure yad displays the completion message
kill $yadPid 2>/dev/null
rm -f "$tmpPipe"
else else
dialog --title "$title" \ dialog --title "$title" \
--progressbox "$text" 20 70 --progressbox "$text" 20 70

View File

@@ -526,6 +526,7 @@ while getopts "${args}" i ; do
i) game_installer;; i) game_installer;;
I) I)
export game="${OPTARG}" export game="${OPTARG}"
export noninteractiveInstall="true"
break;; break;;
k) kill_game;; k) kill_game;;
L) license;; L) license;;
@@ -552,16 +553,19 @@ done
# If agmNoLaunch is set, exit (script is being sourced) # If agmNoLaunch is set, exit (script is being sourced)
[[ "$agmNoLaunch" == "true" ]] && exit 0 [[ "$agmNoLaunch" == "true" ]] && exit 0
# If no game specified, exit # Only proceed with noninteractive installation if explicitly requested
[[ ${#game} -lt 1 ]] && exit 0 if [[ "$noninteractiveInstall" == "true" ]]; then
# If no game specified for noninteractive install, exit
[[ ${#game} -lt 1 ]] && exit 0
# Install the specified game noninteractively # Install the specified game noninteractively
if [[ -f ".install/${game}.sh" ]]; then if [[ -f ".install/${game}.sh" ]]; then
export LANG="en_US.UTF-8" export LANG="en_US.UTF-8"
. ".install/${game}.sh" . ".install/${game}.sh"
# Show success message # Show success message
agm_msgbox "Installation Complete" "Audio Game Installer" "Game \"${game}\" has been successfully installed." agm_msgbox "Installation Complete" "Audio Game Installer" "Game \"${game}\" has been successfully installed."
else else
agm_msgbox "Audio Game Installer" "" "Error: Game '${game}' not found in .install directory" agm_msgbox "Audio Game Installer" "" "Error: Game '${game}' not found in .install directory"
exit 1 exit 1
fi
fi fi