Compare commits

..

1 Commits

Author SHA1 Message Date
aclist
1bd7306784
Merge 23fb10f48e into 936dfe8d02 2025-10-16 13:39:01 +00:00
3 changed files with 27 additions and 120 deletions

View File

@ -3,18 +3,12 @@
## [6.0.0-beta.8] XXXX-XX-XX
## Added
- Flag to disable branch toggle for distro-packaged releases
- Test whether script was sourced inline
- Commandline usage help text
## Fixed
- ESC key destroying wait dialogs while thread is pending
- Tooltip signals being processed on main menu
- Leaky variable name in dialog title
- Prevent extraneous signals from propagating when column width is adjusted
- Script failing to start when remote endpoints are unavailable
## Changed
- Optimize time cost of setup checks
## [6.0.0-beta.7] 2025-09-20
## Added

137
dzgui.sh
View File

@ -63,14 +63,17 @@ testing_url="$url_prefix/testing"
releases_url="https://github.com/$author/$repo/releases/download/browser"
km_helper_url="$releases_url/latlon"
set_im_module(){
#TODO: drop pending SteamOS changes
if pgrep -a gamescope | grep -q "generate-drm-mode"; then
unset GTK_IM_MODULE
pgrep -a gamescope | grep -q "generate-drm-mode"
if [[ $? -eq 0 ]]; then
GTK_IM_MODULE=""
logger INFO "Detected Steam Deck (Game Mode), unsetting GTK_IM_MODULE"
else
return
fi
}
redact(){
sed 's@\(/home/\)[^/]*@\1REDACTED@g'
}
@ -84,21 +87,13 @@ logger(){
printf "%s␞%s␞%s::%s()::%s␞%s\n" "$date" "$tag" "$self" "$caller" "$line" "$string" \
| redact >> "$debug_log"
}
setup_dirs(){
directories=()
directories+=("$state_path")
directories+=("$cache_path")
directories+=("$share_path")
directories+=("$helpers_path")
directories+=("$freedesktop_path")
directories+=("$config_path")
directories+=("$log_path")
for dir in "${directories[@]}"; do
mkdir -p "$dir"
for dir in "$state_path" "$cache_path" "$share_path" "$helpers_path" "$freedesktop_path" "$config_path" "$log_path"; do
if [[ ! -d $dir ]]; then
mkdir -p "$dir"
fi
done
}
setup_state_files(){
if [[ -f "$debug_log" ]]; then
rm "$debug_log" && touch $debug_log
@ -109,8 +104,9 @@ setup_state_files(){
logger INFO "Migrating legacy version file"
fi
# wipe cache files
if [[ $(ls -A "$cache_path") ]]; then
for file in "$cache_path"/*; do
local path="$cache_path"
if find "$path" -mindepth 1 -maxdepth 1 | read; then
for file in $path/*; do
rm "$file"
done
logger INFO "Wiped cache files"
@ -225,7 +221,8 @@ END
}
depcheck(){
for dep in "${!deps[@]}"; do
if ! command -v "$dep" &> /dev/null; then
command -v "$dep" 2>&1>/dev/null
if [[ $? -eq 1 ]]; then
local msg="Requires $dep >= ${deps[$dep]}"
raise_error_and_quit "$msg"
fi
@ -496,47 +493,20 @@ stale_symlinks(){
unlink "$l"
done
}
check_availability() {
if [[ -z $1 ]]; then
return 1
fi
local url=$1
local timeout_sec="3"
if [[ $2 ]]; then
timeout_sec=$2
fi
if ! ping -w "$timeout_sec" "$url" > /dev/null 2>&1; then
logger WARN "Failed to reach $url, service may be down."
return 1
fi
}
local_latlon(){
if [[ -z $(command -v dig) ]]; then
local url_ipecho="https://ipecho.net/plain"
if ! check_availability "ipecho.net"; then
logger WARN "Failed to get external ip address, ipecho.net service may be down."
return 1
fi
local local_ip=$(curl -Ls "$url_ipecho")
local local_ip=$(curl -Ls "https://ipecho.net/plain")
else
# TODO : implement checking remote
local local_ip=$(dig -4 +short myip.opendns.com @resolver1.opendns.com)
fi
local url_ip_api="http://ip-api.com/json/$local_ip"
if ! check_availability "ip-api.com"; then
logger WARN "Failed to get local coordinates, ip-api.com service may be down."
return 1
fi
local res=$(curl -Ls "$url_ip_api" | jq -r '"\(.lat)\n\(.lon)"')
local url="http://ip-api.com/json/$local_ip"
local res=$(curl -Ls "$url" | jq -r '"\(.lat)\n\(.lon)"')
if [[ -z "$res" ]]; then
logger WARN "Failed to get local coordinates"
return 1
fi
echo "$res" > "$coords_file"
}
lock(){
[[ ! -f $lock_file ]] && touch $lock_file
local pid=$(cat $lock_file)
@ -615,7 +585,7 @@ fetch_helpers_by_sum(){
[[ -f "$config_file" ]] && source "$config_file"
declare -A sums
sums=(
["funcs"]="6ae3ead7034dc8e7543472bddee75c63"
["funcs"]="65134f86b7c9e14173e05d8e3ebea101"
["query_v2.py"]="55d339ba02512ac69de288eb3be41067"
["servers.py"]="ed442c3aecf33f777d59dcf53650d263"
["ui.py"]="f03879f088ad074f2ce3c92607c30202"
@ -1120,61 +1090,13 @@ uninstall(){
rm "$self"
echo "Uninstall routine complete"
}
usage(){
cat <<- EOM
DZGUI - Free and Open Source DayZ launcher
Usage:
dzgui.sh [options]
Description:
When no option is provided, the script launches DZGUI.
Options:
-u, --uninstall:
Uninstalls the software
-v, --version:
Prints the version
-h, --help:
Prints this message
EOM
}
main(){
# setup zenity environment
local zenv=""
zenv=$(zenity --version 2>/dev/null)
local zenv=$(zenity --version 2>/dev/null)
[[ -z $zenv ]] && { echo "Requires zenity >= ${deps[$steamsafe_zenity]}"; exit 1; }
# parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
"--uninstall" | "-u")
uninstall
exit 0
# shift
;;
"--version" | "-v")
echo $version
exit 0
# shift
;;
"--help" | "-h")
usage
exit 0
# shift
;;
*)
echo "Unrecognized command!"
return 1
esac
done
if [[ $1 == "--uninstall" ]] || [[ $1 == "-u" ]]; then
uninstall &&
exit 0
fi
set_im_module
@ -1183,12 +1105,7 @@ main(){
printf "All OK. Kicking off UI...\n"
python3 "$ui_helper" "--init-ui" "$version" "$is_steam_deck"
}
if [[ $(basename "$0") == "dzgui.sh" ]]; then
main "$@"
#TODO: tech debt: cruddy handling for steam forking
[[ $? -eq 1 ]] && pkill -f dzgui.sh
fi
main "$@"
#TODO: tech debt: cruddy handling for steam forking
[[ $? -eq 1 ]] && pkill -f dzgui.sh

View File

@ -369,10 +369,6 @@ local_latlon(){
get_dist(){
shift
local given_ip="$1"
if [[ ! -f $_cache_coords ]]; then
printf "Unknown"
return
fi
readarray -t coords < "$_cache_coords"
readarray -t n < <(<<< "$given_ip" awk 'BEGIN{RS="."}{$1=$1}1')