1
0
Fork 0
mirror of https://github.com/aclist/dztui.git synced 2024-12-29 13:52:03 +01:00

fix: flatpak hotfixes

This commit is contained in:
aclist 2023-01-20 02:05:11 +09:00
parent 15bd9b398f
commit 4e0bb3cc3f

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -o pipefail set -o pipefail
version=3.2.0 version=3.2.1
aid=221100 aid=221100
game="dayz" game="dayz"
@ -194,6 +194,9 @@ staging_dir="$staging_dir"
#Path to default Steam client #Path to default Steam client
default_steam_path="$default_steam_path" default_steam_path="$default_steam_path"
#Preferred Steam launch command (for Flatpak support)
preferred_client="$preferred_client"
END END
} }
write_desktop_file(){ write_desktop_file(){
@ -340,7 +343,7 @@ steam_deck_mods(){
rc=$? rc=$?
if [[ $rc -eq 0 ]]; then if [[ $rc -eq 0 ]]; then
echo "[DZGUI] Opening ${workshop}$next" echo "[DZGUI] Opening ${workshop}$next"
"$sbp_cmd" steam://url/CommunityFilePage/$next 2>/dev/null & "$steam_cmd" steam://url/CommunityFilePage/$next 2>/dev/null &
$steamsafe_zenity --info --title="DZGUI" --ok-label="Next" --text="Click [Next] to continue mod check." --width=500 2>/dev/null $steamsafe_zenity --info --title="DZGUI" --ok-label="Next" --text="Click [Next] to continue mod check." --width=500 2>/dev/null
else else
return 1 return 1
@ -380,7 +383,7 @@ manual_mod_install(){
[[ -f $ex ]] && return 1 [[ -f $ex ]] && return 1
local downloads_dir="$steam_path/steamapps/workshop/downloads/$aid" local downloads_dir="$steam_path/steamapps/workshop/downloads/$aid"
local workshop_dir="$steam_path/steamapps/workshop/content/$aid" local workshop_dir="$steam_path/steamapps/workshop/content/$aid"
"$sbp_cmd" "steam://url/CommunityFilePage/${stage_mods[$i]}" "$steam_cmd" "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." 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 sleep 1s
foreground foreground
@ -467,7 +470,7 @@ auto_mod_install(){
[[ -f "/tmp/dz.status" ]] && rm "/tmp/dz.status" [[ -f "/tmp/dz.status" ]] && rm "/tmp/dz.status"
touch "/tmp/dz.status" touch "/tmp/dz.status"
console_dl "$diff" && console_dl "$diff" &&
"$sbp_cmd" steam://open/downloads && 2>/dev/null 1>&2 "$steam_cmd" steam://open/downloads && 2>/dev/null 1>&2
win=$(xdotool search --name "DZG Watcher") win=$(xdotool search --name "DZG Watcher")
xdotool windowactivate $win xdotool windowactivate $win
until [[ -z $(comm -23 <(printf "%s\n" "${modids[@]}" | sort) <(ls -1 $workshop_dir | sort)) ]]; do until [[ -z $(comm -23 <(printf "%s\n" "${modids[@]}" | sort) <(ls -1 $workshop_dir | sort)) ]]; do
@ -1095,15 +1098,15 @@ force_update_mods(){
fi fi
} }
toggle_steam_binary(){ toggle_steam_binary(){
case $sbp_cmd in case "$steam_cmd" in
steam) steam)
sbp_cmd="xdg-open"
steam_cmd="flatpak run com.valvesoftware.Steam" steam_cmd="flatpak run com.valvesoftware.Steam"
update_steam_cmd
popup 700 popup 700
;; ;;
xdg-open) flatpak*)
sbp_cmd="steam"
steam_cmd="steam" steam_cmd="steam"
update_steam_cmd
popup 800;; popup 800;;
esac esac
} }
@ -1120,35 +1123,36 @@ options_menu(){
) )
#TODO: tech debt: drop old flags #TODO: tech debt: drop old flags
[[ $auto_install -eq 2 ]] || [[ $auto_install -eq 1 ]] && debug_list+=("Force update local mods") [[ $auto_install -eq 2 ]] || [[ $auto_install -eq 1 ]] && debug_list+=("Force update local mods")
case $sbp_cmd in case "$steam_cmd" in
steam) steam_hr=Steam ;; steam) steam_hr=Steam ;;
xdg-open) steam_hr=Flatpak ;; flatpak*) steam_hr=Flatpak ;;
esac esac
[[ $toggle_steam -eq 1 ]] && debug_list+=("Toggle native Steam or Flatpak [$steam_hr]") [[ $toggle_steam -eq 1 ]] && debug_list+=("Toggle native Steam or Flatpak [$steam_hr]")
debug_sel=$($steamsafe_zenity --list --width=1280 --height=800 --column="Options" --title="DZGUI" --hide-header "${debug_list[@]}" 2>/dev/null) debug_sel=$($steamsafe_zenity --list --width=1280 --height=800 --column="Options" --title="DZGUI" --hide-header "${debug_list[@]}" 2>/dev/null)
[[ -z $debug_sel ]] && return [[ -z $debug_sel ]] && return
if [[ $debug_sel == "${debug_list[0]}" ]]; then case "$debug_sel" in
enforce_dl=1 "Toggle branch")
toggle_branch && enforce_dl=1
check_version toggle_branch &&
elif [[ $debug_sel == "${debug_list[1]}" ]]; then check_version
toggle_debug ;;
elif [[ $debug_sel == "${debug_list[2]}" ]]; then "Toggle debug mode") toggle_debug ;;
source_script=$(realpath "$0") "Generate debug log")
source_dir=$(dirname "$source_script") source_script=$(realpath "$0")
generate_log > "$source_dir/DZGUI.log" source_dir=$(dirname "$source_script")
printf "[DZGUI] Wrote log file to %s/log\n" "$source_dir" generate_log > "$source_dir/DZGUI.log"
$steamsafe_zenity --info --width 500 --title="DZGUI" --text="Wrote log file to \n$source_dir/log" 2>/dev/null printf "[DZGUI] Wrote log file to %s/log\n" "$source_dir"
elif [[ $debug_sel == "${debug_list[3]}" ]]; then $steamsafe_zenity --info --width 500 --title="DZGUI" --text="Wrote log file to \n$source_dir/log" 2>/dev/null
toggle_console_dl ;;
elif [[ $debug_sel == "${debug_list[4]}" ]]; then Toggle[[:space:]]auto*) toggle_console_dl ;;
force_update=1 "Force update local mods")
force_update_mods force_update=1
merge_modlists > >($steamsafe_zenity --pulsate --progress --no-cancel --auto-close --title=DZGUI --width=500 2>/dev/null) force_update_mods
auto_mod_install merge_modlists > >($steamsafe_zenity --pulsate --progress --no-cancel --auto-close --title=DZGUI --width=500 2>/dev/null)
elif [[ $debug_sel == "${debug_list[5]}" ]]; then auto_mod_install
toggle_steam_binary ;;
fi Toggle[[:space:]]native*) toggle_steam_binary ;;
esac
} }
query_and_connect(){ query_and_connect(){
[[ -z $whitelist ]] && { popup 600; return; } [[ -z $whitelist ]] && { popup 600; return; }
@ -1770,6 +1774,14 @@ fetch_helpers(){
mkdir -p "$helpers_path" mkdir -p "$helpers_path"
[[ ! -f "$helpers_path/vdf2json.py" ]] && curl -Ls "$vdf2json_url" > "$helpers_path/vdf2json.py" [[ ! -f "$helpers_path/vdf2json.py" ]] && curl -Ls "$vdf2json_url" > "$helpers_path/vdf2json.py"
} }
update_steam_cmd(){
local new_cmd
preferred_client="$steam_cmd"
new_cmd="preferred_client=\"$preferred_client\""
mv $config_file ${config_path}dztuirc.old
nr=$(awk '/preferred_client=/ {print NR}' ${config_path}dztuirc.old)
awk -v "var=$new_cmd" -v "nr=$nr" 'NR==nr {$0=var}{print}' ${config_path}dztuirc.old > ${config_path}dztuirc
}
steam_deps(){ steam_deps(){
local flatpak steam local flatpak steam
flatpak=$(flatpak list | grep valvesoftware.Steam) flatpak=$(flatpak list | grep valvesoftware.Steam)
@ -1779,13 +1791,12 @@ steam_deps(){
exit exit
elif [[ -n "$steam" ]] && [[ -n "$flatpak" ]]; then elif [[ -n "$steam" ]] && [[ -n "$flatpak" ]]; then
toggle_steam=1 toggle_steam=1
sbp_cmd="steam"
steam_cmd="steam" steam_cmd="steam"
[[ -n $preferred_client ]] && steam_cmd="$preferred_client"
[[ -z $preferred_client ]] && update_steam_cmd
elif [[ -n "$steam" ]]; then elif [[ -n "$steam" ]]; then
sbp_cmd="steam"
steam_cmd="steam" steam_cmd="steam"
else else
sbp_cmd="xdg-open"
steam_cmd="flatpak run com.valvesoftware.Steam" steam_cmd="flatpak run com.valvesoftware.Steam"
fi fi
} }
@ -1793,12 +1804,12 @@ initial_setup(){
echo "# Initial setup" echo "# Initial setup"
run_depcheck run_depcheck
watcher_deps watcher_deps
steam_deps
check_architecture check_architecture
check_version check_version
check_map_count check_map_count
fetch_helpers fetch_helpers
config config
steam_deps
run_varcheck run_varcheck
stale_symlinks stale_symlinks
init_items init_items