Added yad dialogues if in GUI session, retains the dialog interface if in console.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user