Added yad dialogues if in GUI session, retains the dialog interface if in console.

This commit is contained in:
Storm Dragon
2025-08-01 15:25:53 -04:00
parent 15f90a7979
commit 76f0c66c96
16 changed files with 392 additions and 113 deletions

View File

@ -8,6 +8,16 @@
# Dialog accessibility
export DIALOGOPTS='--no-lines --visit-items'
# Detect dialog interface type BEFORE potentially setting DISPLAY
if [[ -z "$DISPLAY" ]]; then
dialogType="dialog"
else
dialogType="yad"
fi
# Source dialog interface wrapper
source "${0%/*}/../.includes/dialog-interface.sh"
# Turn off debug messages
export WINEDEBUG="-all"
# Make sure display is set in case installed from console.
@ -21,9 +31,9 @@ prefix="https://www.cepstral.com/downloads/installers/windows/"
register() {
local v="$1"
company="$(dialog --clear --inputbox "Company name (leave empty if none)" -1 -1 --stdout)" || exit $?
customer="$(dialog --clear --inputbox "Customer name" -1 -1 --stdout)" || exit $?
key="$(dialog --clear --inputbox "License key" -1 -1 --stdout)" || exit $?
company="$(agm_inputbox "Install Cepstral" "Install Cepstral" "Company name (leave empty if none)" "")" || exit $?
customer="$(agm_inputbox "Install Cepstral" "Install Cepstral" "Customer name" "")" || exit $?
key="$(agm_inputbox "Install Cepstral" "Install Cepstral" "License key" "")" || exit $?
eval "wine \"c:\\Program Files\\Cepstral\\bin\\swift.exe\" --reg-voice --voice-name \"$v\" --customer-name \"$customer\" --company-name \"$company\" --license-key \"$key\""
exit 0
}
@ -75,10 +85,7 @@ declare -a bottle
for i in $(find ~/.local/wine/ -maxdepth 1 -type d -not -name 'wine' | sort) ; do
bottle+=("$i" "${i##*/}")
done
export WINEPREFIX="$(dialog --backtitle "Use the up and down arrow keys to find the option you want, then press enter to select it." \
--clear \
--no-tags \
--menu "Select A Wine Bottle" 0 0 0 "${bottle[@]}" --stdout)"
export WINEPREFIX="$(agm_menu "Install Cepstral" "Install Cepstral" "Select A Wine Bottle" "${bottle[@]}")"
if [[ -z "${WINEPREFIX}" ]]; then
@ -90,10 +97,7 @@ if [[ "$1" == "-r" || "$1" == "--register" ]]; then
action="register"
fi
voice="$(dialog --backtitle "Use the up and down arrow keys to find the option you want, then press enter to select it." \
--clear \
--no-tags \
--menu "Select A voice to $action" 0 0 0 "${voices[@]}" --stdout)"
voice="$(agm_menu "Install Cepstral" "Install Cepstral" "Select A voice to $action" "${voices[@]}")"
if [[ "$action" == "register" ]]; then
register $voice
@ -103,7 +107,7 @@ fi
mkdir -p ~/Downloads
if ! [[ -e ~/Downloads/Cepstral_${voice}_windows_${version}.${msiexe} ]]; then
wget -P ~/Downloads/ "${prefix}Cepstral_${voice}_windows_${version}.${msiexe}" | dialog --progressbox "Downloading voice..." -1 -1
wget -P ~/Downloads/ "${prefix}Cepstral_${voice}_windows_${version}.${msiexe}" | agm_progressbox "Install Cepstral" "Downloading voice..."
fi
# Get the install command.
@ -114,7 +118,7 @@ cmd="${cmd} ~/Downloads/Cepstral_${voice}_windows_${version}.${msiexe}"
# Install the voice
(eval "$cmd" &
[ "$msiexe" = "exe" ] && xdotool sleep 20 key --delay 75 alt+n key --delay 75 alt+a key --delay 75 alt+n key --delay 75 alt+o key --delay 75 alt+i sleep 20 key --delay 75 alt+f
wineserver -w) | dialog --progressbox "installing voice..." -1 -1
wineserver -w) | agm_progressbox "Install Cepstral" "Installing voice..."
# Make voices louder.
find "${WINEPREFIX}/drive_c/Program Files/Cepstral/voices" -type d -not -name voices -exec bash -c 'for d ; do echo "GAIN 2.5" > "$d/default.sfx";done' _ {} \;

View File

@ -42,6 +42,16 @@
#--code--
# Detect dialog interface type BEFORE potentially setting DISPLAY
if [[ -z "$DISPLAY" ]]; then
dialogType="dialog"
else
dialogType="yad"
fi
# Source dialog interface wrapper
source "${0%/*}/../.includes/dialog-interface.sh"
help() {
echo "${0##*/}"
echo "Released under the terms of the Common Public Attribution License Version 1.0"
@ -84,14 +94,14 @@ declare -A command=(
msgbox() {
# Returns: None
# Shows the provided message on the screen with an ok button.
dialog --clear --msgbox "$*" 0 0
agm_msgbox "Set Voice" "Set Voice" "$*"
}
infobox() {
# Returns: None
# Shows the provided message on the screen with no buttons.
local timeout=3
dialog --infobox "$*" 0 0
agm_infobox "Set Voice" "Set Voice" "$*"
read -n1 -t $timeout continue
# Clear any keypresses from the buffer
read -t 0.01 continue
@ -102,7 +112,7 @@ yesno() {
# Args: Question to user.
# Called in if $(yesno) == "Yes"
# Or variable=$(yesno)
dialog --clear --backtitle "Press 'Enter' for "yes" or 'Escape' for "no"." --yesno "$*" 0 0 --stdout
agm_yesno "Set Voice" "Set Voice" "$*"
if [[ $? -eq 0 ]]; then
echo "Yes"
else
@ -117,12 +127,7 @@ menulist() {
for i in "${@}" ; do
menuList+=("$i" "$i")
done
dialog --backtitle "Use the up and down arrow keys to find the option you want, then press enter to select it." \
--clear \
--extra-button \
--extra-label "Test Voice" \
--no-tags \
--menu "Please select one" 0 0 0 "${menuList[@]}" --stdout
agm_menu "Set Voice" "Set Voice" "Please select one" "${menuList[@]}"
return $?
}
@ -251,10 +256,7 @@ if [[ -z "${bottle}" ]]; then
exit 1
fi
export WINEPREFIX="$(dialog --backtitle "Use the up and down arrow keys to find the option you want, then press enter to select it." \
--clear \
--no-tags \
--menu "Select A Wine Bottle" 0 0 0 "${bottles[@]}" --stdout)"
export WINEPREFIX="$(agm_menu "Set Voice" "Set Voice" "Select A Wine Bottle" "${bottles[@]}")"
fi
if [[ -z "${WINEPREFIX}" ]]; then
@ -303,7 +305,7 @@ done
oldVoice="$($grep -P '"DefaultTokenId"="HKEY_LOCAL_MACHINE\\\\(SOFTWARE|Software)\\\\(Wow6432Node\\\\|)Microsoft\\\\Speech\\\\Voices\\\\Token(Enum|)s\\\\[^"]+"' "${WINEPREFIX}/user.reg" | $sed -E -e 's/"DefaultTokenId"="([^"]+)"/\1/g')"
exit=1
if [[ "${#voiceList[@]}" -eq 0 ]]; then
dialog --msgbox "No voices found in ${WINEPREFIX}. Make sure SAPI voices are installed in this Wine prefix." 0 0
agm_msgbox "Set Voice" "Set Voice" "No voices found in ${WINEPREFIX}. Make sure SAPI voices are installed in this Wine prefix."
exit 1
fi
while [[ $exit -ne 0 ]] ; do