From fa80331a63046d6a84fb802032a96ebd717fecf9 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 6 Aug 2025 15:47:59 -0400 Subject: [PATCH] Ported over ui updates from Linux Game Manager. --- .includes/dialog-interface.sh | 48 +++++++++++++++++++++++++++-------- .includes/functions.sh | 13 +++++++--- .includes/update.sh | 4 ++- 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/.includes/dialog-interface.sh b/.includes/dialog-interface.sh index 5248278..5a61196 100644 --- a/.includes/dialog-interface.sh +++ b/.includes/dialog-interface.sh @@ -165,12 +165,12 @@ agm_msgbox() { local text="$3" if [[ "$dialogType" == "yad" ]]; then - yad --form \ + echo -e "$text" | yad --text-info \ --title="$title" \ - --field="$text:LBL" \ - --selectable-labels \ + --show-cursor \ --button="OK:0" \ - --width=400 + --width=600 \ + --height=400 else dialog --backtitle "$backTitle" \ --title "$title" \ @@ -186,13 +186,13 @@ agm_yesno() { local text="$3" if [[ "$dialogType" == "yad" ]]; then - yad --form \ + echo -e "$text" | yad --text-info \ --title="$title" \ - --field="$text:LBL" \ - --selectable-labels \ + --show-cursor \ --button="Yes:0" \ --button="No:1" \ - --width=400 + --width=600 \ + --height=400 else dialog --backtitle "$backTitle" \ --title "$title" \ @@ -361,8 +361,36 @@ agm_progress_with_percent() { local text="$2" if [[ "$dialogType" == "yad" ]]; then - # Create a true progress dialog that accepts percentage updates - yad --progress \ + # Start audio feedback for accessibility + local beepPid + local yadPid + + # Cleanup function for traps + cleanup_percent_progress() { + [[ -n "$beepPid" ]] && kill "$beepPid" 2>/dev/null + [[ -n "$yadPid" ]] && kill "$yadPid" 2>/dev/null + } + + # Set trap to ensure cleanup on interruption + trap cleanup_percent_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 + + # Create a true progress dialog that accepts percentage updates with tee for cleanup + { + cat + cleanup_percent_progress + trap - EXIT INT TERM + } | yad --progress \ --title="$title" \ --text="$text" \ --auto-close \ diff --git a/.includes/functions.sh b/.includes/functions.sh index 8db8e0d..b73ae3a 100644 --- a/.includes/functions.sh +++ b/.includes/functions.sh @@ -54,9 +54,16 @@ download() { # Skip if the item is in cache. [[ -e "${cache}/${dest}" ]] && continue if [[ "$dialogType" == "yad" ]]; then - # Use curl's progress bar with better accessibility for yad - if ! curl -L4 -C - --retry 10 --progress-bar --output "${cache}/${dest}" "${i}" 2>&1 | \ - sed -u 's/.*\r\([0-9]*\)%.*/\1/' | agm_progress_with_percent "Audio Game Manager" "Downloading \"$dest\"..."; then + # Use curl's progress bar with better parsing for yad + if ! { + curl -L4 -C - --retry 10 --progress-bar --output "${cache}/${dest}" "${i}" 2>&1 | \ + stdbuf -oL grep -o '[0-9]*%' | \ + stdbuf -oL sed -u 's/%$//' | \ + while read -r percent; do + echo "$percent" + echo "# Downloading $dest - ${percent}%" + done + } | agm_progress_with_percent "Audio Game Manager" "Downloading \"$dest\"..."; then agm_infobox "Audio Game Manager" "Audio Game Manager" "Could not download \"$dest\". Installation cannot continue." exit 1 fi diff --git a/.includes/update.sh b/.includes/update.sh index 5b2ea05..33fb5d4 100644 --- a/.includes/update.sh +++ b/.includes/update.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Check for latest news check_news() { # For use by update scripts that want to source functions in this file. @@ -45,7 +47,7 @@ fi # Get the important information: commit messages and summary local changesSummary changesSummary=$({ - echo "=== UPDATE COMPLETED ===" + echo "UPDATE COMPLETED" echo echo "Recent changes:" git log '@{1}..' --pretty=format:'• %an: %s' | tac