From ea2c5291a57d9774e996a99f52e5653eea9f48c1 Mon Sep 17 00:00:00 2001 From: aclist Date: Thu, 11 May 2023 12:10:27 +0900 Subject: [PATCH] fix: restore beta client logic --- dzgui.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 37646d4..7f12d76 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/bin/bash set -o pipefail -version=3.3.0-rc.25 +version=3.3.0-rc.26 aid=221100 game="dayz" @@ -1014,6 +1014,38 @@ toggle_branch(){ printf "[DZGUI] Toggled branch to '$branch'\n" source $config_file } +is_beta(){ + local dir="$default_steam_path/package" + if [[ -f $dir/beta ]]; then + echo 0 + else + echo 1 + fi +} +focus_beta_client(){ + wid(){ + wmctrl -ilx | awk 'tolower($3) == "steam.steam"' | grep 'Steam$' | awk '{print $1}' + } + until [[ -n $(wid) ]]; do + : + done + wmctrl -ia $(wid) + sleep 0.1s + wid=$(xdotool getactivewindow) + local geo=$(xdotool getwindowgeometry $wid) + local pos=$(<<< "$geo" awk 'NR==2 {print $2}' | sed 's/,/ /') + local dim=$(<<< "$geo" awk 'NR==3 {print $2}' | sed 's/x/ /') + local pos1=$(<<< "$pos" awk '{print $1}') + local pos2=$(<<< "$pos" awk '{print $2}') + local dim1=$(<<< "$dim" awk '{print $1}') + local dim2=$(<<< "$dim" awk '{print $2}') + local dim1=$(((dim1/2)+pos1)) + local dim2=$(((dim2/2)+pos2)) + xdotool mousemove $dim1 $dim2 + xdotool click 1 + sleep 0.5s + xdotool key Tab +} generate_log(){ cat <<-DOC Linux: $(uname -mrs) @@ -1034,14 +1066,24 @@ console_dl(){ sleep 1s #https://github.com/jordansissel/xdotool/issues/67 #https://dwm.suckless.org/patches/current_desktop/ - local wid=$(xdotool search --onlyvisible --name Steam) - #xdotool windowactivate $wid sleep 1.5s for i in "${modids[@]}"; do - xdotool type --delay 0 "workshop_download_item $aid $i" - sleep 0.5s - xdotool key --window $wid Return - sleep 0.5s + if [[ $(is_beta) -eq 0 ]]; then + if [[ ${#modids[@]} -eq 1 ]]; then + focus_beta_client + fi + else + wid=0 + until [[ $(xdotool getwindowname $wid 2>/dev/null) == "Steam" ]]; do + wid=$(xdotool getactivewindow) + done + xdotool windowfocus $wid + xdotool key Tab + fi + xdotool type --delay 0 "workshop_download_item $aid $i" + sleep 0.5s + xdotool key Return + sleep 0.5s done } find_default_path(){