From 09352b2f0b7f8394c30b001e6f165cac2a250704 Mon Sep 17 00:00:00 2001 From: aclist Date: Sun, 9 Oct 2022 11:07:07 +0900 Subject: [PATCH] Create foreground function --- dzgui.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 7945a09..ad78e42 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/bin/bash set -o pipefail -version=2.8.0-rc.21 +version=2.8.0-rc.22 aid=221100 game="dayz" @@ -80,6 +80,13 @@ depcheck(){ command -v $dep 2>&1>/dev/null || (printf "Requires %s >=%s\n" $dep ${deps[$dep]}; exit 1) done } +watcher_deps(){ + if [[ ! $(command -v wmctrl) ]] || [[ ! $(command -v xdotool) ]]; then + echo "100" + warn "Requires wmctrl or xdotool" + exit 1 + fi +} init_items(){ #array order determines menu selector; this is destructive items=( @@ -419,6 +426,15 @@ test_display_mode(){ pgrep -a gamescope | grep -q "generate-drm-mode" [[ $? -eq 0 ]] && gamemode=1 } +foreground(){ + if [[ $(command -v wmctrl) ]]; then + wmctrl -a "DZG Watcher" + else + + local window_id=$(xdotool search --name "DZG Watcher") + xdotool windowactivate $window_id + fi +} manual_mod_install(){ [[ $is_steam_deck -eq 1 ]] && test_display_mode if [[ $gamemode -eq 1 ]]; then @@ -435,7 +451,7 @@ manual_mod_install(){ steam "steam://url/CommunityFilePage/${stage_mods[$i]}" echo "# Opening workshop page for ${stage_mods[$i]}. If you see no progress after subscribing, try unsubscribing and resubscribing again until the download commences." sleep 1s - wmctrl -a "DZG Watcher" + foreground until [[ -d $downloads_dir/${stage_mods[$i]} ]]; do [[ -f $ex ]] && return 1 sleep 0.1s @@ -443,13 +459,13 @@ manual_mod_install(){ break fi done - wmctrl -a "DZG Watcher" + foreground echo "# Steam is downloading ${stage_mods[$i]} (mod $((i+1)) of ${#stage_mods[@]})" until [[ -d $workshop_dir/${stage_mods[$i]} ]]; do [[ -f $ex ]] && return 1 sleep 0.1s done - wmctrl -a "DZG Watcher" + foreground echo "# ${stage_mods[$i]} moved to mods dir" done echo "100" @@ -1605,6 +1621,7 @@ fetch_scmd_helper(){ initial_setup(){ echo "# Initial setup" run_depcheck + watcher_deps check_architecture check_version check_map_count