Totally fubar progress bars. Attempted fix here. Also add progress beeps because yad isn't the most accessible thing with progress dialogues.

This commit is contained in:
Storm Dragon
2025-08-06 00:54:34 -04:00
parent 775d48c068
commit 9a7b440423

View File

@@ -226,19 +226,52 @@ agm_progressbox() {
local text="$2" local text="$2"
if [[ "$dialogType" == "yad" ]]; then if [[ "$dialogType" == "yad" ]]; then
# Use accessible form approach without temp files # Start audio feedback for accessibility
# Process command output first to get summary info 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 lineCount=0
local lastLine="Starting..." local lastLine="Starting..."
local allOutput=""
# Collect output while command runs
while IFS= read -r line; do while IFS= read -r line; do
((lineCount++)) ((lineCount++))
lastLine="$line" lastLine="$line"
allOutput="${allOutput}${line}\n"
done < <(stdbuf -oL cat) done < <(stdbuf -oL cat)
# Clean up background processes
cleanup_progress
trap - EXIT INT TERM # Remove traps
# Show completion dialog with accessible summary # Show completion dialog with accessible summary
yad --form \ yad --form \
--title="$title" \ --title="$title" \
@@ -249,7 +282,7 @@ agm_progressbox() {
--selectable-labels \ --selectable-labels \
--button="OK:0" \ --button="OK:0" \
--width=500 \ --width=500 \
--height=200 --height=150
else else
dialog --title "$title" \ dialog --title "$title" \
--progressbox "$text" 20 70 --progressbox "$text" 20 70
@@ -263,18 +296,46 @@ agm_simple_progressbox() {
local text="$2" local text="$2"
if [[ "$dialogType" == "yad" ]]; then 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 \ yad --progress \
--title="$title" \ --title="$title" \
--text="$text" \ --text="$text" \
--auto-close \ --auto-close \
--pulsate \
--width=400 \ --width=400 \
--height=100 & --height=100 &
local yadPid=$! yadPid=$!
# Read from stdin and discard, but keep yad window open until command finishes
# Read from stdin and discard, but keep dialogs open until command finishes
cat > /dev/null 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 else
dialog --title "$title" \ dialog --title "$title" \
--progressbox "$text" 20 70 --progressbox "$text" 20 70