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:08:13 +09:00
parent 2701b7eeb7
commit 68e0b1d5fc

View file

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