mirror of
https://github.com/aclist/dztui.git
synced 2024-12-29 13:52:03 +01:00
feat: support kdialog
This commit is contained in:
parent
6beca3a6d0
commit
b5502f9675
1 changed files with 52 additions and 38 deletions
60
dzgui.sh
60
dzgui.sh
|
@ -375,7 +375,11 @@ steam_deck_mods(){
|
||||||
}
|
}
|
||||||
test_display_mode(){
|
test_display_mode(){
|
||||||
pgrep -a gamescope | grep -q "generate-drm-mode"
|
pgrep -a gamescope | grep -q "generate-drm-mode"
|
||||||
[[ $? -eq 0 ]] && gamemode=1
|
if [[ $? -eq 0 ]]; then
|
||||||
|
echo gm
|
||||||
|
else
|
||||||
|
echo dm
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
foreground(){
|
foreground(){
|
||||||
if [[ $(command -v wmctrl) ]]; then
|
if [[ $(command -v wmctrl) ]]; then
|
||||||
|
@ -389,11 +393,6 @@ manual_mod_install(){
|
||||||
local ip="$1"
|
local ip="$1"
|
||||||
local gameport="$2"
|
local gameport="$2"
|
||||||
|
|
||||||
[[ $is_steam_deck -eq 1 ]] && test_display_mode
|
|
||||||
if [[ $gamemode -eq 1 ]]; then
|
|
||||||
popup 1400
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
local ex="/tmp/dzc.tmp"
|
local ex="/tmp/dzc.tmp"
|
||||||
[[ -f $ex ]] && rm $ex
|
[[ -f $ex ]] && rm $ex
|
||||||
watcher(){
|
watcher(){
|
||||||
|
@ -605,6 +604,10 @@ connect(){
|
||||||
compare
|
compare
|
||||||
[[ $auto_install -eq 2 ]] && merge_modlists > >(pdialog)
|
[[ $auto_install -eq 2 ]] && merge_modlists > >(pdialog)
|
||||||
if [[ -n $diff ]]; then
|
if [[ -n $diff ]]; then
|
||||||
|
if [[ $is_steam_deck -eq 1 ]] && [[ $(test_display_mode) == "gm" ]]; then
|
||||||
|
popup 1400
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
case $auto_install in
|
case $auto_install in
|
||||||
1|2) auto_mod_install "$ip" "$gameport" ;;
|
1|2) auto_mod_install "$ip" "$gameport" ;;
|
||||||
*) manual_mod_install "$ip" "$gameport" ;;
|
*) manual_mod_install "$ip" "$gameport" ;;
|
||||||
|
@ -662,10 +665,9 @@ fetch_ip_metadata(){
|
||||||
curl -Ls "$url"
|
curl -Ls "$url"
|
||||||
}
|
}
|
||||||
|
|
||||||
#TODO: local servers
|
validate_local_ip(){
|
||||||
#local_ip(){
|
<<< "$1" grep -qP '(^127.\d+.\d+.\d+:\d+$)|(^10\.\d+.\d+.\d+:\d+$)|(^172\.1[6-9]\.\d+.\d+:\d+$)|(^172\.2[0-9]\.\d+.\d+:\d+$)|(^172\.3[0-1]\.\d+.\d+:\d+$)|(^192\.168\.\d+.\d+:\d+$)'
|
||||||
#(^127\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)
|
}
|
||||||
#}
|
|
||||||
test_steam_api(){
|
test_steam_api(){
|
||||||
local url="https://api.steampowered.com/IGameServersService/GetServerList/v1/?filter=\appid\221100&limit=10&key=$steam_api"
|
local url="https://api.steampowered.com/IGameServersService/GetServerList/v1/?filter=\appid\221100&limit=10&key=$steam_api"
|
||||||
local code=$(curl -ILs "$url" | grep -E "^HTTP")
|
local code=$(curl -ILs "$url" | grep -E "^HTTP")
|
||||||
|
@ -731,19 +733,33 @@ connect_by_ip(){
|
||||||
connect "$ip" "$gameport" "$qport"
|
connect "$ip" "$gameport" "$qport"
|
||||||
}
|
}
|
||||||
parse_ips(){
|
parse_ips(){
|
||||||
|
local res
|
||||||
source $config_file
|
source $config_file
|
||||||
check_steam_api
|
check_steam_api
|
||||||
[[ $? -eq 1 ]] && return
|
[[ $? -eq 1 ]] && return
|
||||||
while true; do
|
while true; do
|
||||||
local ip
|
local ip
|
||||||
ip=$($steamsafe_zenity --entry --text="Enter server IP (omit port)" --title="DZGUI" 2>/dev/null)
|
ip=$(edialog "Enter server IP (for LAN servers, include query port in IP:PORT format)")
|
||||||
[[ $? -eq 1 ]] && return 1
|
[[ $? -eq 1 ]] && return 1
|
||||||
[[ $ip =~ ':' ]] && continue
|
if [[ $ip =~ ':' ]]; then
|
||||||
|
if ! validate_local_ip "$ip"; then
|
||||||
|
warn "Invalid local IP. Check IP:PORT combination and try again."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
local lan_ip=$(<<< $ip awk -F: '{print $1}')
|
||||||
|
local lan_qport=$(<<< $ip awk -F: '{print $2}')
|
||||||
|
res=$(a2s $lan_ip $lan_qport info)
|
||||||
|
if [[ ! $? -eq 0 ]] || [[ $(<<< $res jq '.response|length') -eq 0 ]]; then
|
||||||
|
warn "Failed to retrieve server metadata. Check IP:PORT combination and try again."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
ip_table "$res"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
if validate_ip "$ip"; then
|
if validate_ip "$ip"; then
|
||||||
local res
|
|
||||||
res=$(fetch_ip_metadata "$ip")
|
res=$(fetch_ip_metadata "$ip")
|
||||||
if [[ ! $? -eq 0 ]] || [[ $(<<< $res jq '.response|length') -eq 0 ]]; then
|
if [[ ! $? -eq 0 ]] || [[ $(<<< $res jq '.response|length') -eq 0 ]]; then
|
||||||
warn "Failed to retrieve IP metadata. Check IP or API key and try again."
|
warn "Failed to retrieve server metadata. Check IP or API key and try again."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
local ct=$(<<< "$res" jq '.response.servers|length')
|
local ct=$(<<< "$res" jq '.response.servers|length')
|
||||||
|
@ -761,6 +777,7 @@ parse_ips(){
|
||||||
else
|
else
|
||||||
warn "Invalid IP"
|
warn "Invalid IP"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
query_defunct(){
|
query_defunct(){
|
||||||
|
@ -953,8 +970,6 @@ list_mods(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
connect_to_fav(){
|
connect_to_fav(){
|
||||||
#TODO: test with broken/bogus fav
|
|
||||||
#TODO: test backing out of connection dialogs
|
|
||||||
logger INFO "${FUNCNAME[0]}"
|
logger INFO "${FUNCNAME[0]}"
|
||||||
|
|
||||||
local fav="$1"
|
local fav="$1"
|
||||||
|
@ -1126,7 +1141,7 @@ popup(){
|
||||||
1100) pop "No results found." ;;
|
1100) pop "No results found." ;;
|
||||||
1200) pop "Timed out. Server may be temporarily offline or not responding to queries." ;;
|
1200) pop "Timed out. Server may be temporarily offline or not responding to queries." ;;
|
||||||
1300) pop "No favorite server configured." ;;
|
1300) pop "No favorite server configured." ;;
|
||||||
1400) pop "DZGUI must be run in Desktop Mode on Steam Deck, preferably via the desktop shortcut." ;;
|
1400) pop "To install missing mods, run DZGUI via Desktop Mode on Steam Deck, preferably via the desktop shortcut." ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
toggle_console_dl(){
|
toggle_console_dl(){
|
||||||
|
@ -1431,7 +1446,7 @@ choose_filters(){
|
||||||
if [[ $sels =~ Keyword ]]; then
|
if [[ $sels =~ Keyword ]]; then
|
||||||
local search
|
local search
|
||||||
while true; do
|
while true; do
|
||||||
search=$($steamsafe_zenity --entry --text="Search (case insensitive)" --width=500 --title="DZGUI" 2>/dev/null | awk '{print tolower($0)}')
|
search=$(edialog "Search (case insensitive)" | awk '{print tolower($0)}')
|
||||||
[[ $? -eq 1 ]] && return 1
|
[[ $? -eq 1 ]] && return 1
|
||||||
[[ -z $search ]] && warn "Cannot submit an empty keyword"
|
[[ -z $search ]] && warn "Cannot submit an empty keyword"
|
||||||
[[ -n $search ]] && break
|
[[ -n $search ]] && break
|
||||||
|
@ -1749,11 +1764,6 @@ check_architecture(){
|
||||||
if [[ -n "$cpu" ]]; then
|
if [[ -n "$cpu" ]]; then
|
||||||
is_steam_deck=1
|
is_steam_deck=1
|
||||||
logger INFO "Setting architecture to 'Steam Deck'"
|
logger INFO "Setting architecture to 'Steam Deck'"
|
||||||
[[ $is_steam_deck -eq 1 ]] && test_display_mode
|
|
||||||
if [[ $gamemode -eq 1 ]]; then
|
|
||||||
popup 1400 &&
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
is_steam_deck=0
|
is_steam_deck=0
|
||||||
logger INFO "Setting architecture to 'desktop'"
|
logger INFO "Setting architecture to 'desktop'"
|
||||||
|
@ -1839,7 +1849,11 @@ pdialog(){
|
||||||
$steamsafe_zenity --progress --pulsate --auto-close --title="DZGUI" --width=500 2>/dev/null
|
$steamsafe_zenity --progress --pulsate --auto-close --title="DZGUI" --width=500 2>/dev/null
|
||||||
}
|
}
|
||||||
edialog(){
|
edialog(){
|
||||||
|
if [[ $is_steam_deck -eq 1 ]] && [[ $(test_display_mode) == "gm" ]]; then
|
||||||
|
kdialog --inputbox "$1" --title "DZGUI" --geometry 500 2>/dev/null
|
||||||
|
else
|
||||||
$steamsafe_zenity --entry --text="$1" --width=500 --title="DZGUI" 2>/dev/null
|
$steamsafe_zenity --entry --text="$1" --width=500 --title="DZGUI" 2>/dev/null
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
tdialog(){
|
tdialog(){
|
||||||
$steamsafe_zenity --info --text="$1" --width=500 --title="DZGUI" 2>/dev/null
|
$steamsafe_zenity --info --text="$1" --width=500 --title="DZGUI" 2>/dev/null
|
||||||
|
|
Loading…
Reference in a new issue