From f82df9eacf2b61a4ed52daa5469970a2a682fa77 Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Sat, 18 Oct 2025 22:51:52 +0200 Subject: [PATCH 01/10] Clean up set_im_module --- dzgui.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 9237455..0b78c20 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -63,17 +63,14 @@ 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 - pgrep -a gamescope | grep -q "generate-drm-mode" - if [[ $? -eq 0 ]]; then - GTK_IM_MODULE="" + if pgrep -a gamescope | grep -q "generate-drm-mode"; then + unset GTK_IM_MODULE logger INFO "Detected Steam Deck (Game Mode), unsetting GTK_IM_MODULE" - else - return fi } + redact(){ sed 's@\(/home/\)[^/]*@\1REDACTED@g' } From d34293e2c8d5c2066008713278df25fb0351333e Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Sat, 18 Oct 2025 22:52:13 +0200 Subject: [PATCH 02/10] Clean up setup_dirs --- dzgui.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 0b78c20..a2fab92 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -84,13 +84,20 @@ logger(){ printf "%s␞%s␞%s::%s()::%s␞%s\n" "$date" "$tag" "$self" "$caller" "$line" "$string" \ | redact >> "$debug_log" } + setup_dirs(){ - 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 + 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" done } + setup_state_files(){ if [[ -f "$debug_log" ]]; then rm "$debug_log" && touch $debug_log From d53476399dfd85351de8df537c9af3236df45c6f Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Sat, 18 Oct 2025 22:52:49 +0200 Subject: [PATCH 03/10] Clean up setup_state_files --- dzgui.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index a2fab92..ddd06d8 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -108,9 +108,8 @@ setup_state_files(){ logger INFO "Migrating legacy version file" fi # wipe cache files - local path="$cache_path" - if find "$path" -mindepth 1 -maxdepth 1 | read; then - for file in $path/*; do + if [[ $(ls "$cache_path") ]]; then + for file in "$cache_path"/*; do rm "$file" done logger INFO "Wiped cache files" From 6bb59f4060ae4a79e2046bc94c86dffd2ffe20ed Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Sat, 18 Oct 2025 22:53:14 +0200 Subject: [PATCH 04/10] Clean up depcheck --- dzgui.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index ddd06d8..fef6d3b 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -224,8 +224,7 @@ END } depcheck(){ for dep in "${!deps[@]}"; do - command -v "$dep" 2>&1>/dev/null - if [[ $? -eq 1 ]]; then + if ! command -v "$dep" &> /dev/null; then local msg="Requires $dep >= ${deps[$dep]}" raise_error_and_quit "$msg" fi From cf087d96c72169664e114f987252d8af7ace6bfc Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Sat, 18 Oct 2025 23:12:31 +0200 Subject: [PATCH 05/10] Add check for script sourcing --- dzgui.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index fef6d3b..8038974 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1107,7 +1107,12 @@ main(){ printf "All OK. Kicking off UI...\n" python3 "$ui_helper" "--init-ui" "$version" "$is_steam_deck" + } -main "$@" -#TODO: tech debt: cruddy handling for steam forking -[[ $? -eq 1 ]] && pkill -f dzgui.sh + +if [[ $(basename "$0") == "dzgui.sh" ]]; then + main "$@" + + #TODO: tech debt: cruddy handling for steam forking + [[ $? -eq 1 ]] && pkill -f dzgui.sh +fi From f2124218e4bd7530ef1333bfbb657c3426beb90b Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Sat, 18 Oct 2025 23:12:59 +0200 Subject: [PATCH 06/10] Add handling for multiple argument, version getting option and help --- dzgui.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 8038974..be85a48 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1092,13 +1092,59 @@ uninstall(){ rm "$self" echo "Uninstall routine complete" } + +read -r -d '' helptext <<- 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(){ - local zenv=$(zenity --version 2>/dev/null) + # setup zenity environment + local zenv="" + zenv=$(zenity --version 2>/dev/null) [[ -z $zenv ]] && { echo "Requires zenity >= ${deps[$steamsafe_zenity]}"; exit 1; } - if [[ $1 == "--uninstall" ]] || [[ $1 == "-u" ]]; then - uninstall && - exit 0 - fi + + # parse arguments + while [[ $# -gt 0 ]]; do + case $1 in + "--uninstall" | "-u") + uninstall + exit 0 + # shift + ;; + "--version" | "-v") + echo $version + exit 0 + # shift + ;; + "--help" | "-h") + echo "$helptext" + exit 0 + # shift + ;; + *) + echo "Unrecognized command!" + return 1 + esac + done set_im_module From 1dfe9cd9df2624604e7c1cc8bc9516a91d0fc86f Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Tue, 21 Oct 2025 19:04:38 +0000 Subject: [PATCH 07/10] Fix not checking dotfiles in cache path --- dzgui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dzgui.sh b/dzgui.sh index be85a48..296daa0 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -108,7 +108,7 @@ setup_state_files(){ logger INFO "Migrating legacy version file" fi # wipe cache files - if [[ $(ls "$cache_path") ]]; then + if [[ $(ls -A "$cache_path") ]]; then for file in "$cache_path"/*; do rm "$file" done From 5a54d43601be24092d09654c84b5d159a004488c Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 23 Oct 2025 13:38:56 +0900 Subject: [PATCH 08/10] fix: encapsulate usage command --- dzgui.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dzgui.sh b/dzgui.sh index 296daa0..c6b8a16 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1093,6 +1093,7 @@ uninstall(){ echo "Uninstall routine complete" } +usage(){ read -r -d '' helptext <<- EOM DZGUI - Free and Open Source DayZ launcher @@ -1115,6 +1116,8 @@ Options: -h, --help: Prints this message EOM +echo "$helptext" +} main(){ # setup zenity environment @@ -1136,7 +1139,7 @@ main(){ # shift ;; "--help" | "-h") - echo "$helptext" + usage exit 0 # shift ;; From d0de2974d8d16c7ba810f92d82ccfd80adf37cc2 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 23 Oct 2025 13:44:50 +0900 Subject: [PATCH 09/10] fix: emit heredoc directly --- dzgui.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index c6b8a16..53dd4f2 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1094,7 +1094,7 @@ uninstall(){ } usage(){ -read -r -d '' helptext <<- EOM +cat <<- EOM DZGUI - Free and Open Source DayZ launcher Usage: @@ -1116,7 +1116,6 @@ Options: -h, --help: Prints this message EOM -echo "$helptext" } main(){ From ec7daf7f6be4a57b0c29b5eefeed40afe56e6396 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 23 Oct 2025 13:57:19 +0900 Subject: [PATCH 10/10] fix: store filepaths in array I opted to encapsulate these in an array because I was paranoid about needing to separate each directory with a whitespace when storing them on a stringwise basis. This should be safer and ensure the paths don't get concatenated together if the whitespace is omitted. --- dzgui.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 53dd4f2..58975c8 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -86,14 +86,15 @@ logger(){ } setup_dirs(){ - 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 + 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" done }