Add error message type

Does not clear the screen in terminal mode so stderr is preserved
This commit is contained in:
the-sane 2023-01-27 09:53:10 -05:00
parent f7580b8fdc
commit 7ee873d2bb

View File

@ -314,6 +314,12 @@ message() {
margs=("--warning" "--window-icon=\"$lug_logo\"" "--text=") margs=("--warning" "--window-icon=\"$lug_logo\"" "--text=")
shift 1 # drop the message type argument and shift up to the text shift 1 # drop the message type argument and shift up to the text
;; ;;
"error")
# error message
# call format: message error "text to display"
margs=("--error" "--window-icon=\"$lug_logo\"" "--text=")
shift 1 # drop the message type argument and shift up to the text
;;
"question") "question")
# question # question
# call format: if message question "question to ask?"; then... # call format: if message question "question to ask?"; then...
@ -354,6 +360,12 @@ message() {
printf "\n$2\n\n" printf "\n$2\n\n"
read -n 1 -s -p "Press any key..." read -n 1 -s -p "Press any key..."
;; ;;
"error")
# error message. Does not clear the screen
# call format: message error "text to display"
printf "\n$2\n\n"
read -n 1 -s -p "Press any key..."
;;
"question") "question")
# question # question
# call format: if message question "question to ask?"; then... # call format: if message question "question to ask?"; then...
@ -538,7 +550,7 @@ menu_loop_done() {
getdirs() { getdirs() {
# Sanity checks # Sanity checks
if [ ! -d "$conf_dir" ]; then if [ ! -d "$conf_dir" ]; then
message warning "Config directory not found. The Helper is unable to proceed.\n\n$conf_dir" message error "Config directory not found. The Helper is unable to proceed.\n\n$conf_dir"
return 1 return 1
fi fi
if [ ! -d "$conf_dir/$conf_subdir" ]; then if [ ! -d "$conf_dir/$conf_subdir" ]; then
@ -571,7 +583,7 @@ getdirs() {
if [ -z "$wine_prefix" ]; then if [ -z "$wine_prefix" ]; then
wine_prefix="$(zenity --file-selection --directory --title="Select your Star Citizen WINE prefix directory" --filename="$HOME/Games/star-citizen" 2>/dev/null)" wine_prefix="$(zenity --file-selection --directory --title="Select your Star Citizen WINE prefix directory" --filename="$HOME/Games/star-citizen" 2>/dev/null)"
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message warning "An unexpected error has occurred. The Helper is unable to proceed." message error "An unexpected error has occurred. The Helper is unable to proceed."
return 1 return 1
elif [ -z "$wine_prefix" ]; then elif [ -z "$wine_prefix" ]; then
# User clicked cancel # User clicked cancel
@ -588,7 +600,7 @@ getdirs() {
else else
while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/$install_path" 2>/dev/null)"; do while game_path="$(zenity --file-selection --directory --title="Select your Star Citizen directory" --filename="$wine_prefix/$install_path" 2>/dev/null)"; do
if [ "$?" -eq -1 ]; then if [ "$?" -eq -1 ]; then
message warning "An unexpected error has occurred. The Helper is unable to proceed." message error "An unexpected error has occurred. The Helper is unable to proceed."
return 1 return 1
elif [ "$(basename "$game_path")" != "$sc_base_dir" ]; then elif [ "$(basename "$game_path")" != "$sc_base_dir" ]; then
message warning "You must select the base game directory named '$sc_base_dir'\n\nie. [prefix]/drive_c/Program Files/Roberts Space Industries/StarCitizen" message warning "You must select the base game directory named '$sc_base_dir'\n\nie. [prefix]/drive_c/Program Files/Roberts Space Industries/StarCitizen"
@ -992,7 +1004,7 @@ preflight_check() {
# Try to execute the actions as root # Try to execute the actions as root
try_exec "$preflight_actions_string" try_exec "$preflight_actions_string"
if [ "$?" -eq 1 ]; then if [ "$?" -eq 1 ]; then
message info "Authentication failed or there was an error.\nSee terminal for more information.\n\nReturning to main menu." message error "Authentication failed or there was an error.\nSee terminal for more information.\n\nReturning to main menu."
return 0 return 0
fi fi
fi fi
@ -1730,8 +1742,7 @@ runner_manage() {
missing_dir="false" missing_dir="false"
for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
if [ ! -d "${download_dirs[i]}" ]; then if [ ! -d "${download_dirs[i]}" ]; then
message warning "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}" message error "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
debug_print continue "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
missing_dir="true" missing_dir="true"
fi fi
done done
@ -1783,8 +1794,7 @@ dxvk_manage() {
missing_dir="false" missing_dir="false"
for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do for (( i=1; i<"${#download_dirs[@]}"; i=i+2 )); do
if [ ! -d "${download_dirs[i]}" ]; then if [ ! -d "${download_dirs[i]}" ]; then
message warning "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}" message error "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
debug_print continue "The following Lutris directory was not found. Unable to continue.\n\n${download_dirs[i]}"
missing_dir="true" missing_dir="true"
fi fi
done done
@ -2141,7 +2151,7 @@ eac_workaround() {
# Try to modify /etc/hosts as root # Try to modify /etc/hosts as root
try_exec "printf '\n$eac_hosts #Star Citizen EAC workaround\n' >> /etc/hosts" try_exec "printf '\n$eac_hosts #Star Citizen EAC workaround\n' >> /etc/hosts"
if [ "$?" -eq 1 ]; then if [ "$?" -eq 1 ]; then
message info "Authentication failed or there was an error modifying /etc/hosts.\nSee terminal for more information.\n\nReturning to main menu." message error "Authentication failed or there was an error modifying /etc/hosts.\nSee terminal for more information.\n\nReturning to main menu."
return 0 return 0
fi fi