From 738f85d5bda787f7cf6fa5a3d75e96cf3839f3cc Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Mon, 25 Aug 2025 12:02:55 -0400 Subject: [PATCH] More robust dependency notifications Not all systems have notify-send by default. Try zenity first. --- lug-helper.sh | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index 6877f9e..e721022 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -35,30 +35,46 @@ fi # Check for dependencies if [ ! -x "$(command -v curl)" ]; then -# Print to stderr and also try warning the user through notify-send +# Print to stderr and also try warning the user through zenity or notify-send printf "lug-helper.sh: The required package 'curl' was not found on this system.\n" 1>&2 - notify-send "lug-helper" "The required package 'curl' was not found on this system.\n" --icon=dialog-warning + if [ -x "$(command -v zenity)" ]; then + zenity --error --width="400" --title="Star Citizen LUG Helper" --text="The required package 'curl' was not found on this system." + elif [ -x "$(command -v notify-send)" ]; then + notify-send "lug-helper" "The required package 'curl' was not found on this system.\n" --icon=dialog-warning + fi exit 1 fi if [ ! -x "$(command -v mktemp)" ] || [ ! -x "$(command -v chmod)" ] || [ ! -x "$(command -v sort)" ] || [ ! -x "$(command -v basename)" ] || [ ! -x "$(command -v realpath)" ] || [ ! -x "$(command -v dirname)" ] || [ ! -x "$(command -v cut)" ] || [ ! -x "$(command -v numfmt)" ] || [ ! -x "$(command -v tr)" ] || [ ! -x "$(command -v od)" ] || [ ! -x "$(command -v readlink)" ]; then # coreutils - # Print to stderr and also try warning the user through notify-send - printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that coreutils is installed!\n" 1>&2 - notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that coreutils is installed!\n" --icon=dialog-warning + # Print to stderr and also try warning the user through zenity or notify-send + printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that 'coreutils' is installed!\n" 1>&2 + if [ -x "$(command -v zenity)" ]; then + zenity --error --width="400" --title="Star Citizen LUG Helper" --text="One or more required packages were not found on this system.\n\nPlease check that 'coreutils' is installed!" + elif [ -x "$(command -v notify-send)" ]; then + notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that 'coreutils' is installed!\n" --icon=dialog-warning + fi exit 1 fi if [ ! -x "$(command -v xargs)" ]; then # findutils - # Print to stderr and also try warning the user through notify-send - printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that the following findutils packages are installed:\n- xargs\n" 1>&2 - notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following findutils packages are installed:\n- xargs\n" --icon=dialog-warning + # Print to stderr and also try warning the user through zenity or notify-send + printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that 'findutils' or the following packages are installed:\n- xargs\n" 1>&2 + if [ -x "$(command -v zenity)" ]; then + zenity --error --width="400" --title="Star Citizen LUG Helper" --text="One or more required packages were not found on this system.\n\nPlease check that 'findutils' or the following packages are installed:\n- xargs" + elif [ -x "$(command -v notify-send)" ]; then + notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that 'findutils' or the following packages are installed:\n- xargs\n" --icon=dialog-warning + fi exit 1 fi if [ ! -x "$(command -v cabextract)" ] || [ ! -x "$(command -v unzip)" ]; then # winetricks dependencies - # Print to stderr and also try warning the user through notify-send + # Print to stderr and also try warning the user through zenity or notify-send printf "lug-helper.sh: One or more required packages were not found on this system.\nPlease check that the following winetricks dependencies (or winetricks itself) are installed:\n- cabextract\n- unzip\n" 1>&2 - notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following winetricks dependencies (or winetricks itself) are installed:\n- cabextract\n- unzip\n" --icon=dialog-warning + if [ -x "$(command -v zenity)" ]; then + zenity --error --width="400" --title="Star Citizen LUG Helper" --text="One or more required packages were not found on this system.\n\nPlease check that the following winetricks dependencies (or winetricks itself) are installed:\n- cabextract\n- unzip" + elif [ -x "$(command -v notify-send)" ]; then + notify-send "lug-helper" "One or more required packages were not found on this system.\nPlease check that the following winetricks dependencies (or winetricks itself) are installed:\n- cabextract\n- unzip\n" --icon=dialog-warning + fi exit 1 fi