From f82df9eacf2b61a4ed52daa5469970a2a682fa77 Mon Sep 17 00:00:00 2001 From: Gergely Koloszar Date: Sat, 18 Oct 2025 22:51:52 +0200 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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