From 9a7b440423a528c1bf51eac36496b55f6ed28dfa Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 6 Aug 2025 00:54:34 -0400 Subject: [PATCH] Totally fubar progress bars. Attempted fix here. Also add progress beeps because yad isn't the most accessible thing with progress dialogues. --- .includes/dialog-interface.sh | 85 ++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/.includes/dialog-interface.sh b/.includes/dialog-interface.sh index 182de42..a0080e8 100644 --- a/.includes/dialog-interface.sh +++ b/.includes/dialog-interface.sh @@ -226,19 +226,52 @@ agm_progressbox() { local text="$2" if [[ "$dialogType" == "yad" ]]; then - # Use accessible form approach without temp files - # Process command output first to get summary info + # Start audio feedback for accessibility + local beepPid + local yadPid + + # Cleanup function for traps + cleanup_progress() { + [[ -n "$beepPid" ]] && kill "$beepPid" 2>/dev/null + [[ -n "$yadPid" ]] && kill "$yadPid" 2>/dev/null + } + + # Set trap to ensure cleanup on interruption + trap cleanup_progress EXIT INT TERM + + if command -v sox >/dev/null 2>&1; then + { + while true; do + # Generate a short, pleasant progress beep (440Hz for 0.1s) + sox -q -n -d synth 0.1 sine 440 vol 0.3 2>/dev/null + sleep 2 # Beep every 2 seconds + done + } & + beepPid=$! + fi + + # Start visual progress dialog with auto-close + yad --progress \ + --title="$title" \ + --text="$text" \ + --auto-close \ + --pulsate \ + --width=400 \ + --height=100 & + yadPid=$! + + # Process command output local lineCount=0 local lastLine="Starting..." - local allOutput="" - - # Collect output while command runs while IFS= read -r line; do ((lineCount++)) lastLine="$line" - allOutput="${allOutput}${line}\n" done < <(stdbuf -oL cat) + # Clean up background processes + cleanup_progress + trap - EXIT INT TERM # Remove traps + # Show completion dialog with accessible summary yad --form \ --title="$title" \ @@ -249,7 +282,7 @@ agm_progressbox() { --selectable-labels \ --button="OK:0" \ --width=500 \ - --height=200 + --height=150 else dialog --title "$title" \ --progressbox "$text" 20 70 @@ -263,18 +296,46 @@ agm_simple_progressbox() { local text="$2" if [[ "$dialogType" == "yad" ]]; then - # Just show a simple status with no pulsating - more accessible + # Start audio feedback for accessibility + local beepPid + local yadPid + + # Cleanup function for traps + cleanup_simple_progress() { + [[ -n "$beepPid" ]] && kill "$beepPid" 2>/dev/null + [[ -n "$yadPid" ]] && kill "$yadPid" 2>/dev/null + } + + # Set trap to ensure cleanup on interruption + trap cleanup_simple_progress EXIT INT TERM + + if command -v sox >/dev/null 2>&1; then + { + while true; do + # Generate a short, pleasant progress beep (440Hz for 0.1s) + sox -q -n -d synth 0.1 sine 440 vol 0.3 2>/dev/null + sleep 2 # Beep every 2 seconds + done + } & + beepPid=$! + fi + + # Show progress dialog with pulsating yad --progress \ --title="$title" \ --text="$text" \ --auto-close \ + --pulsate \ --width=400 \ --height=100 & - local yadPid=$! - # Read from stdin and discard, but keep yad window open until command finishes + yadPid=$! + + # Read from stdin and discard, but keep dialogs open until command finishes cat > /dev/null - # Close the progress dialog - kill $yadPid 2>/dev/null + + # Clean up background processes + cleanup_simple_progress + trap - EXIT INT TERM # Remove traps else dialog --title "$title" \ --progressbox "$text" 20 70