From 5080c201b5bf5686224d88eb3926fdbf9f79fa4e Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Sat, 6 Jul 2024 20:43:14 +0900 Subject: [PATCH 01/25] docs: fix url --- docs/dzgui_dark.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dzgui_dark.adoc b/docs/dzgui_dark.adoc index 740b6ad..d79e46c 100644 --- a/docs/dzgui_dark.adoc +++ b/docs/dzgui_dark.adoc @@ -7,7 +7,7 @@ DayZ server browser and mod manager for Linux | Last updated: {d} Click https://aclist.github.io/dzgui/dzgui.html[here] for light mode -Looking for the DZGUI Knowledge Base? Click https://aclist.github.io/dzgui/kb.html[here] +Looking for the DZGUI Knowledge Base? Click https://aclist.github.io/dzgui/kb_dark.html[here] == What this is A GUI version of https://github.com/aclist/dztui[DZTUI] for Linux. From cc05212e3186ef7c764e27647fbb9ddad30153f4 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:43:22 +0900 Subject: [PATCH 02/25] fix: encapsulate player names --- CHANGELOG.md | 4 ++++ dzgui.sh | 2 +- helpers/funcs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddb55ba..577b3c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [5.3.3] 2024-07-16 +### Fixed +- Encapsulate player names correctly so that names with whitespace in them are supported + ## [5.3.2] 2024-07-02 ### Fixed - Server list would sometimes be missing some expected servers due to truncation being caused when a server erroneously set an incomplete gametype diff --git a/dzgui.sh b/dzgui.sh index 5e59ad9..6a505fa 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -538,7 +538,7 @@ fetch_helpers_by_sum(){ ["ui.py"]="f14772424461ec438579dec567db0634" ["query_v2.py"]="1822bd1769ce7d7cb0d686a60f9fa197" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="718c3060b88041f5b99a1ce52b12642f" + ["funcs"]="4a318243c59f6e8ca3aee96cde1f1007" ) local author="aclist" local repo="dztui" diff --git a/helpers/funcs b/helpers/funcs index b36a30b..f8ff5ab 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -1287,7 +1287,7 @@ launch(){ update_symlinks if [[ $debug -eq 1 ]]; then - local launch_options="$steam_cmd -applaunch $aid -connect=$ip:$gameport -nolauncher -nosplash -name=$name -skipintro \"-mod=$concat\"" + local launch_options="$steam_cmd -applaunch $aid -connect=$ip:$gameport -nolauncher -nosplash \"-name=$name\" -skipintro \"-mod=$concat\"" printf "Debug mode: these options would have been used to launch the game: $launch_options" return 0 fi From 89d839d61a7cf26b8fe0d38304bd3864f6188be7 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Tue, 16 Jul 2024 20:43:48 +0900 Subject: [PATCH 03/25] chore: bump version --- dzgui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dzgui.sh b/dzgui.sh index 6a505fa..00d9f62 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.3.2 +version=5.3.3 #CONSTANTS aid=221100 From 3acab049d47696d93113f1afa660b8d5e51421c2 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Tue, 16 Jul 2024 21:28:03 +0900 Subject: [PATCH 04/25] fix: clerical update to #136 --- CHANGELOG.md | 4 ++++ dzgui.sh | 4 ++-- helpers/funcs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 577b3c8..5526c5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [5.3.4] 2024-07-16 +### Fixed +- Clerical update to prior 5.3.3 hotfix + ## [5.3.3] 2024-07-16 ### Fixed - Encapsulate player names correctly so that names with whitespace in them are supported diff --git a/dzgui.sh b/dzgui.sh index 00d9f62..489a7de 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.3.3 +version=5.3.4 #CONSTANTS aid=221100 @@ -538,7 +538,7 @@ fetch_helpers_by_sum(){ ["ui.py"]="f14772424461ec438579dec567db0634" ["query_v2.py"]="1822bd1769ce7d7cb0d686a60f9fa197" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="4a318243c59f6e8ca3aee96cde1f1007" + ["funcs"]="7d7ab9c23d28bbcf40e53a0764afa5e8" ) local author="aclist" local repo="dztui" diff --git a/helpers/funcs b/helpers/funcs index f8ff5ab..bd0a6fe 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -1307,7 +1307,7 @@ final_handshake(){ return 1 fi logger INFO "Kicking off Steam launch" - $steam_cmd -applaunch $aid -connect=$saved_address -nolauncher -nosplash -skipintro -name=$name \"-mod=$saved_mods\" & + $steam_cmd -applaunch $aid -connect=$saved_address -nolauncher -nosplash -skipintro \"-name=$name\" \"-mod=$saved_mods\" & until [[ $(is_dayz_running) -eq 1 ]]; do sleep 0.1s done From 7c4cbecb4755f8445d4c48fa19f03ed93de1f322 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:23:05 +0900 Subject: [PATCH 05/25] fix: pack launch parameters into array #136 --- CHANGELOG.md | 4 ++++ dzgui.sh | 4 ++-- helpers/funcs | 9 ++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5526c5d..a459224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [5.3.5] 2024-07-16 +### Fixed +- Pack launch parameters into array before splitting + ## [5.3.4] 2024-07-16 ### Fixed - Clerical update to prior 5.3.3 hotfix diff --git a/dzgui.sh b/dzgui.sh index 489a7de..cad5320 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.3.4 +version=5.3.5 #CONSTANTS aid=221100 @@ -538,7 +538,7 @@ fetch_helpers_by_sum(){ ["ui.py"]="f14772424461ec438579dec567db0634" ["query_v2.py"]="1822bd1769ce7d7cb0d686a60f9fa197" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="7d7ab9c23d28bbcf40e53a0764afa5e8" + ["funcs"]="e6752185dda9c0e35731bd0b95a3cb19" ) local author="aclist" local repo="dztui" diff --git a/helpers/funcs b/helpers/funcs index bd0a6fe..5119494 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -1307,7 +1307,14 @@ final_handshake(){ return 1 fi logger INFO "Kicking off Steam launch" - $steam_cmd -applaunch $aid -connect=$saved_address -nolauncher -nosplash -skipintro \"-name=$name\" \"-mod=$saved_mods\" & + local params=() + params+=("-connect=$saved_address") + params+=("-nolauncher") + params+=("-nosplash") + params+=("-skipintro") + params+=("\"-name=$name\"") + params+=("\"-mod=$saved_mods\"") + $steam_cmd -applaunch $aid "${params[@]}" & until [[ $(is_dayz_running) -eq 1 ]]; do sleep 0.1s done From e157a26f2af29704e43c929dafaae2cedb4f3a38 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 19 Jul 2024 01:06:13 +0900 Subject: [PATCH 06/25] fix: test for empty dir --- dzgui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dzgui.sh b/dzgui.sh index cad5320..5dcda3e 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -778,7 +778,7 @@ varcheck(){ source "$config_file" local workshop_dir="$steam_path/steamapps/workshop/content/$aid" local game_dir="$steam_path/steamapps/common/DayZ" - if [[ ! -d $steam_path ]] || [[ ! -d $game_dir ]]; then + if [[ ! -d $steam_path ]] || [[ ! -d $game_dir ]] || [[ ! $(find $game_dir -type f) ]]; then logger WARN "DayZ path resolved to '$game_dir'" logger WARN "Workshop path resolved to '$workshop_dir'" qdialog "$msg2" "Yes" "Exit" From 9800e6b34646b01577ca763358c8bb038d05b32d Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 19 Jul 2024 01:06:47 +0900 Subject: [PATCH 07/25] chore: normalize version --- dzgui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dzgui.sh b/dzgui.sh index 5dcda3e..64de5e9 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.3.5 +version=5.3.3 #CONSTANTS aid=221100 From 56a6e7ac3d7e143ca5547e68f5206b56a77114dc Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Sun, 4 Aug 2024 07:57:37 +0900 Subject: [PATCH 08/25] fix: pack player names correctly --- dzgui.sh | 4 ++-- helpers/funcs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 64de5e9..c13d3ed 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.3.3 +version=5.3.3-beta.2 #CONSTANTS aid=221100 @@ -538,7 +538,7 @@ fetch_helpers_by_sum(){ ["ui.py"]="f14772424461ec438579dec567db0634" ["query_v2.py"]="1822bd1769ce7d7cb0d686a60f9fa197" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="e6752185dda9c0e35731bd0b95a3cb19" + ["funcs"]="28728839c031ae99002860a546352455" ) local author="aclist" local repo="dztui" diff --git a/helpers/funcs b/helpers/funcs index 5119494..6fa07eb 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -1287,7 +1287,7 @@ launch(){ update_symlinks if [[ $debug -eq 1 ]]; then - local launch_options="$steam_cmd -applaunch $aid -connect=$ip:$gameport -nolauncher -nosplash \"-name=$name\" -skipintro \"-mod=$concat\"" + local launch_options="$steam_cmd -applaunch $aid -connect=$ip:$gameport -nolauncher -nosplash -name=$name -skipintro -mod=$concat" printf "Debug mode: these options would have been used to launch the game: $launch_options" return 0 fi @@ -1312,13 +1312,14 @@ final_handshake(){ params+=("-nolauncher") params+=("-nosplash") params+=("-skipintro") - params+=("\"-name=$name\"") - params+=("\"-mod=$saved_mods\"") + params+=("-name=$name") + params+=("-mod=$saved_mods") $steam_cmd -applaunch $aid "${params[@]}" & until [[ $(is_dayz_running) -eq 1 ]]; do sleep 0.1s done logger INFO "Caught DayZ process" + printf "\n" return 6 } manual_mod_install(){ From c6a4b419dd16d1469d42d0707625d8e620d29704 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Sun, 4 Aug 2024 08:01:54 +0900 Subject: [PATCH 09/25] chore: update changelog --- CHANGELOG.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a459224..36f36a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,11 @@ # Changelog -## [5.3.5] 2024-07-16 +## [5.3.3-beta.2] 2024-08-03 ### Fixed -- Pack launch parameters into array before splitting +- Clerical hotfix for previous player names fix +- Test if DayZ directory is empty at startup, implying that the game was moved to a new library collection -## [5.3.4] 2024-07-16 -### Fixed -- Clerical update to prior 5.3.3 hotfix - -## [5.3.3] 2024-07-16 +## [5.3.3-beta.1] 2024-07-16 ### Fixed - Encapsulate player names correctly so that names with whitespace in them are supported From e6244370ddb2e77de16d0f0d9d089c295c9dd548 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Mon, 5 Aug 2024 06:03:15 +0900 Subject: [PATCH 10/25] feat: scan LAN servers --- CHANGELOG.md | 4 ++ dzgui.sh | 9 +-- helpers/funcs | 25 ++++++- helpers/lan | 46 ++++++++++++ helpers/query_v2.py | 10 +++ helpers/ui.py | 168 ++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 249 insertions(+), 13 deletions(-) create mode 100755 helpers/lan diff --git a/CHANGELOG.md b/CHANGELOG.md index 36f36a2..9e9297f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [5.3.3-beta.3] 2024-08-04 +### Added +- Scan local area network for DayZ servers + ## [5.3.3-beta.2] 2024-08-03 ### Fixed - Clerical hotfix for previous player names fix diff --git a/dzgui.sh b/dzgui.sh index c13d3ed..090724e 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.3.3-beta.2 +version=5.3.3-beta.3 #CONSTANTS aid=221100 @@ -535,10 +535,11 @@ fetch_helpers_by_sum(){ [[ -f "$config_file" ]] && source "$config_file" declare -A sums sums=( - ["ui.py"]="f14772424461ec438579dec567db0634" - ["query_v2.py"]="1822bd1769ce7d7cb0d686a60f9fa197" + ["ui.py"]="9755d63904fb63dc48eff3397a31de17" + ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="28728839c031ae99002860a546352455" + ["funcs"]="2ebe0f7072f7a9459007b1d9d09e2f4f" + ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" local repo="dztui" diff --git a/helpers/funcs b/helpers/funcs index 6fa07eb..4351ea9 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -44,6 +44,7 @@ _cache_launch="$cache_dir/$prefix.launch_mods" _cache_address="$cache_dir/$prefix.launch_address" _cache_coords="$cache_path/$prefix.coords" _cache_cooldown="$cache_path/$prefix.cooldown" +_cache_lan="$cache_path/$prefix.lan" #XDG freedesktop_path="$HOME/.local/share/applications" @@ -55,6 +56,7 @@ km_helper="$helpers_path/latlon" sums_path="$helpers_path/sums.md5" query_helper="$helpers_path/query_v2.py" func_helper="$helpers_path/funcs" +lan_helper="$helpers_path/lan" #STEAM PATHS workshop_path="$steam_path/steamapps/workshop" @@ -125,8 +127,19 @@ declare -A funcs=( ["force_update"]="force_update" ["Handshake"]="final_handshake" ["get_player_count"]="get_player_count" +["lan_scan"]="lan_scan" ) +lan_scan(){ + local port="$1" + local res + res=$("$lan_helper" "$port") + if [[ $? -ne 0 ]]; then + printf "\n" + else + printf "%s\n" "$res" + fi +} get_player_count(){ shift local res @@ -589,6 +602,16 @@ dump_servers(){ _iterate "$file" "${iters[@]}" fi ;; + *Scan[[:space:]]LAN[[:space:]]servers*) + local port=$(<<< "$subcontext" awk -F: '{print $2}') + local file="$_cache_lan" + if [[ ! $subcontext =~ Name ]]; then + [[ -f $file ]] && rm $file + local lan=$(lan_scan $port) + readarray -t iters <<< "$lan" + _iterate "$file" "${iters[@]}" + fi + ;; esac shift logger INFO "Server context is '$subcontext', reading from file '$file'" @@ -988,8 +1011,6 @@ query_defunct(){ -d "$(payload)" 'https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/?format=json' } local result=$(post | jq -r '.[].publishedfiledetails[] | select(.result==1) | "\(.file_size) \(.publishedfileid)"') - local result2=$(post | jq -r '') - echo "$result2" > $HOME/json <<< "$result" awk '{print $2}' } encode(){ diff --git a/helpers/lan b/helpers/lan new file mode 100755 index 0000000..cf16934 --- /dev/null +++ b/helpers/lan @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +query_name(){ + local ip="$1" + local port="$2" + local api="$HOME/.local/share/dzgui/helpers/query_v2.py" + python3 "$api" "$ip" "$port" test +} + +scan(){ + local ip="$1" + local port="$2" + local res=$(query_name "$ip" "$port") + [[ -z $res ]] && return 1 + printf "%s\n" "${ip}:XXX:${port}" +} + +get_netmask(){ + ip r \ + | awk '/default/ {print $3}' \ + | uniq \ + | awk -F. 'OFS="."{print $1,$2,$3}' +} + +iter(){ + _testping(){ + ping -c1 -i 0.1 -w 1 "$1" 2>/dev/null 1>&2 + [[ $? -eq 0 ]] && echo "$1" + } + export -f _testping + local mask=$(get_netmask) + # GNU parallel is not available OOTB on Steam Deck + for i in $(seq 1 255); do + echo "${mask}.${i}" + done | xargs -I {} -P 200 bash -c '_testping "{}"' +} + +export -f scan +export -f query_name + +DZG_LAN_PORT="$1" + +readarray -t ips < <(iter) +for i in "${ips[@]}"; do + scan "$i" $DZG_LAN_PORT +done diff --git a/helpers/query_v2.py b/helpers/query_v2.py index 4ed62e9..1033d5b 100644 --- a/helpers/query_v2.py +++ b/helpers/query_v2.py @@ -5,6 +5,14 @@ import json from a2s import dayzquery sys.path.append('a2s') +def test_local(ip, qport): + try: + info = a2s.info((ip, int(qport)), 0.5) + name = info.server_name + print(name) + except: + sys.exit(1) + def get_info(ip, qport): try: info = a2s.info((ip, int(qport))) @@ -73,3 +81,5 @@ match mode: get_rules(ip, qport) case "names": get_names(ip, qport) + case "test": + test_local(ip, qport) diff --git a/helpers/ui.py b/helpers/ui.py index b830ce8..4612b40 100644 --- a/helpers/ui.py +++ b/helpers/ui.py @@ -17,6 +17,7 @@ import time locale.setlocale(locale.LC_ALL, '') gi.require_version("Gtk", "3.0") from gi.repository import Gtk, GLib, Gdk, GObject, Pango +from enum import Enum # 5.2.3 app_name = "DZGUI" @@ -91,7 +92,8 @@ connect = [ ("Quick-connect to favorite server",), ("Recent servers",), ("Connect by IP",), - ("Connect by ID",) + ("Connect by ID",), + ("Scan LAN servers",) ] manage = [ ("Add server by IP",), @@ -143,6 +145,7 @@ status_tooltip = { "Recent servers": "Shows the last 10 servers you connected to (includes attempts)", "Connect by IP": "Connect to a server by IP", "Connect by ID": "Connect to a server by Battlemetrics ID", + "Scan LAN servers": "Search for servers on your local network", "Add server by IP": "Add a server by IP", "Add server by ID": "Add a server by Battlemetrics ID", "Change favorite server": "Update your quick-connect server", @@ -570,10 +573,16 @@ class ButtonBox(Gtk.Box): renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(column_title, renderer, text=i) treeview.append_column(column) + self._populate(context) treeview.set_model(row_store) treeview.grab_focus() - def _populate(self, array_context): + def _populate(self, context): + match context: + case 'Manage': array_context = manage + case 'Main menu': array_context = connect + case 'Options': array_context = options + case 'Help': array_context = help row_store.clear() status = array_context[0][0] treeview = self.get_treeview() @@ -606,11 +615,7 @@ class ButtonBox(Gtk.Box): for col in cols: col.set_title(context) - match context: - case 'Manage': self._populate(manage) - case 'Main menu': self._populate(connect) - case 'Options': self._populate(options) - case 'Help': self._populate(help) + self._populate(context) toggle_signal(treeview, treeview.selected_row, '_on_tree_selection_changed', True) @@ -1069,6 +1074,17 @@ class TreeView(Gtk.TreeView): toggle_signal(self.get_outer_grid().right_panel.filters_vbox, check, '_on_check_toggle', True) toggle_signal(self, self, '_on_keypress', True) + if mode == "Scan LAN servers": + lan_dialog = LanButtonDialog(self.get_outer_window()) + port = lan_dialog.get_selected_port() + if port is None: + grid = self.get_outer_grid() + right_panel = grid.right_panel + vbox = right_panel.button_vbox + vbox._update_single_column("Main menu") + return + mode = mode + ":" + port + wait_dialog = GenericDialog(transient_parent, "Fetching server metadata", "WAIT") wait_dialog.show_all() thread = threading.Thread(target=self._background, args=(wait_dialog, mode)) @@ -1304,6 +1320,10 @@ class AppHeaderBar(Gtk.HeaderBar): self.set_decoration_layout("menu:minimize,maximize,close") self.set_show_close_button(True) +class Port(Enum): + # Contains enums for LanButtonDialog ports + DEFAULT = 1 + CUSTOM = 2 class GenericDialog(Gtk.MessageDialog): def __init__(self, parent, text, mode): @@ -1361,6 +1381,140 @@ class GenericDialog(Gtk.MessageDialog): self.format_secondary_text(text) +class LanButtonDialog(Gtk.Window): + def __init__(self, parent): + super().__init__() + + self.buttonBox = Gtk.Box() + + header_label = "Scan LAN servers" + buttons = [ + ( "Use default query port (27016)", Port.DEFAULT ), + ( "Enter custom query port", Port.CUSTOM ), + ] + + self.buttonBox.set_orientation(Gtk.Orientation.VERTICAL) + self.buttonBox.active_button = None + + for i in enumerate(buttons): + + string = i[1][0] + enum = i[1][1] + + button = Gtk.RadioButton(label=string) + button.port = enum + button.connect("toggled", self._on_button_toggled) + + if i[0] == 0: + self.buttonBox.active_button = button + else: + button.join_group(self.buttonBox.active_button) + + self.buttonBox.add(button) + + self.entry = Gtk.Entry() + self.buttonBox.add(self.entry) + self.entry.set_no_show_all(True) + + self.label = Gtk.Label() + self.label.set_text("Invalid port") + self.label.set_no_show_all(True) + self.buttonBox.add(self.label) + + self.dialog = LanDialog(parent, header_label, self.buttonBox, self.entry, self.label) + self.dialog.run() + self.dialog.destroy() + + def get_selected_port(self): + return self.dialog.p + + def _on_button_toggled(self, button): + if button.get_active(): + self.buttonBox.active_button = button + + match button.port: + case Port.DEFAULT: + self.entry.set_visible(False) + case Port.CUSTOM: + self.entry.set_visible(True) + self.entry.grab_focus() + + def get_active_button(): + return self.buttonBox.active_button + +class LanDialog(Gtk.MessageDialog): + # Custom dialog class that performs integer validation and blocks input if invalid port + # Returns None if user cancels the dialog + def __init__(self, parent, text, child, entry, label): + super().__init__(transient_for=parent, + flags=0, + message_type=Gtk.MessageType.INFO, + buttons=Gtk.ButtonsType.OK_CANCEL, + text=text, + secondary_text="Select the query port", + title=app_name, + modal=True, + ) + + self.outer = self.get_content_area() + self.outer.pack_start(child, False, False, 0) + self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) + self.set_size_request(500, 0) + self.outer.set_margin_start(30) + self.outer.set_margin_end(30) + self.outer.show_all() + + self.connect("response", self._on_dialog_response, child, entry) + self.connect("key-press-event", self._on_keypress, entry) + self.connect("key-release-event", self._on_key_release, entry, label) + + self.child = child + + self.p = None + + def _on_key_release(self, dialog, event, entry, label): + label.set_visible(False) + if entry.is_visible() == False or entry.get_text() == "": + return + if self._is_invalid(entry.get_text()): + label.set_visible(True) + else: + label.set_visible(False) + + def _on_keypress(self, a, event, entry): + if event.keyval == Gdk.KEY_Return: + self.response(Gtk.ResponseType.OK) + if event.keyval == Gdk.KEY_Up: + entry.set_text("") + self.child.get_children()[0].grab_focus() + + def _on_dialog_response(self, dialog, resp, child, entry): + match resp: + case Gtk.ResponseType.CANCEL: + return + case Gtk.ResponseType.DELETE_EVENT: + return + + string = entry.get_text() + port = child.active_button.port + + match port: + case Port.DEFAULT: + self.p = "27016" + case Port.CUSTOM: + if self._is_invalid(string): + self.stop_emission_by_name("response") + else: + self.p = string + + def _is_invalid(self, string): + if string.isdigit() == False \ + or int(string) == 0 \ + or int(string[0]) == 0 \ + or int(string) > 65535: + return True + return False + def ChangelogDialog(parent, text, mode): dialog = GenericDialog(parent, text, mode) From 138a6ff7c8d45350dc2d8cbc0c92a88b2566a659 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Mon, 5 Aug 2024 06:08:05 +0900 Subject: [PATCH 11/25] fix: process lan option contextually --- dzgui.sh | 4 ++-- helpers/ui.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 090724e..2d54d84 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.3.3-beta.3 +version=5.3.3-beta.4 #CONSTANTS aid=221100 @@ -535,7 +535,7 @@ fetch_helpers_by_sum(){ [[ -f "$config_file" ]] && source "$config_file" declare -A sums sums=( - ["ui.py"]="9755d63904fb63dc48eff3397a31de17" + ["ui.py"]="c62e84ddd1457b71a85ad21da662b9af" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" ["funcs"]="2ebe0f7072f7a9459007b1d9d09e2f4f" diff --git a/helpers/ui.py b/helpers/ui.py index 4612b40..d988fd0 100644 --- a/helpers/ui.py +++ b/helpers/ui.py @@ -1186,7 +1186,7 @@ class TreeView(Gtk.TreeView): right_panel = outer.grid.right_panel filters_vbox = right_panel.filters_vbox - valid_contexts = ["Server browser", "My saved servers", "Recent servers"] + valid_contexts = ["Server browser", "My saved servers", "Recent servers", "Scan LAN servers"] if chosen_row in valid_contexts: # server contexts share the same model type for check in checks: From 24a916c11cfc9cfdd071a2a7210a887d9e5cfe73 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:27:53 +0900 Subject: [PATCH 12/25] fix: helper file permissions --- dzgui.sh | 5 +++-- helpers/funcs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index 2d54d84..f483d1e 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.3.3-beta.4 +version=5.3.3-beta.5 #CONSTANTS aid=221100 @@ -538,7 +538,7 @@ fetch_helpers_by_sum(){ ["ui.py"]="c62e84ddd1457b71a85ad21da662b9af" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="2ebe0f7072f7a9459007b1d9d09e2f4f" + ["funcs"]="5ebf7c9694c9ec8df00f0b30871eeb38" ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" @@ -577,6 +577,7 @@ fetch_helpers_by_sum(){ logger INFO "Updated '$full_path' to sum '$sum'" fi [[ $file == "funcs" ]] && chmod +x "$full_path" + [[ $file == "lan" ]] && chmod +x "$full_path" done return 0 } diff --git a/helpers/funcs b/helpers/funcs index 4351ea9..9d9c3a9 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -134,7 +134,7 @@ lan_scan(){ local port="$1" local res res=$("$lan_helper" "$port") - if [[ $? -ne 0 ]]; then + if [[ -z $res ]]; then printf "\n" else printf "%s\n" "$res" From 4bd7f684c2005e2277f8a138124b1e58cd8db112 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Wed, 28 Aug 2024 06:52:01 +0900 Subject: [PATCH 13/25] fix: detect APU variants --- dzgui.sh | 55 +++++++++++++++++++++++++++++++++---------- helpers/funcs | 3 ++- helpers/ui.py | 2 +- images/icons/128.png | Bin 0 -> 32867 bytes images/icons/16.png | Bin 0 -> 1067 bytes images/icons/24.png | Bin 0 -> 1660 bytes images/icons/256.png | Bin 0 -> 121255 bytes images/icons/32.png | Bin 0 -> 2723 bytes images/icons/48.png | Bin 0 -> 5587 bytes images/icons/64.png | Bin 0 -> 9391 bytes images/icons/96.png | Bin 0 -> 19666 bytes 11 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 images/icons/128.png create mode 100644 images/icons/16.png create mode 100644 images/icons/24.png create mode 100644 images/icons/256.png create mode 100644 images/icons/32.png create mode 100644 images/icons/48.png create mode 100644 images/icons/64.png create mode 100644 images/icons/96.png diff --git a/dzgui.sh b/dzgui.sh index f483d1e..680a355 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -13,7 +13,7 @@ sd_res="--width=1280 --height=800" steamsafe_zenity="/usr/bin/zenity" zenity_flags=("--width=500" "--title=DZGUI") declare -A deps -deps=([awk]="5.1.1" [curl]="7.80.0" [jq]="1.6" [tr]="9.0" [$steamsafe_zenity]="3.42.1") +deps=([awk]="5.1.1" [curl]="7.80.0" [jq]="1.6" [tr]="9.0" [$steamsafe_zenity]="3.44.1") #CONFIG config_path="$HOME/.config/dztui" @@ -65,6 +65,7 @@ km_helper_url="$releases_url/latlon" geo_file_url="$releases_url/ips.csv.gz" set_im_module(){ + #TODO: drop pending SteamOS changes pgrep -a gamescope | grep -q "generate-drm-mode" if [[ $? -eq 0 ]]; then GTK_IM_MODULE="" @@ -377,18 +378,20 @@ test_display_mode(){ fi } check_architecture(){ - local cpu=$(< /proc/cpuinfo grep "AMD Custom APU 0405") - if [[ -n "$cpu" ]]; then - if [[ $(test_display_mode) == "gm" ]]; then - is_steam_deck=2 - else - is_steam_deck=1 - fi - logger INFO "Setting architecture to 'Steam Deck'" - else + local cpu=$(< /proc/cpuinfo awk -F": " '/AMD Custom APU [0-9]{4}$/ {print $2; exit}') + read -a APU_MODEL <<< "$cpu" + if [[ ${APU_MODEL[3]} != "0932" ]] || [[ ${APU_MODEL[3]} != "0405" ]]; then is_steam_deck=0 logger INFO "Setting architecture to 'desktop'" + return fi + + if [[ $(test_display_mode) == "gm" ]]; then + is_steam_deck=2 + else + is_steam_deck=1 + fi + logger INFO "Setting architecture to 'Steam Deck'" } check_map_count(){ [[ $is_steam_deck -gt 0 ]] && return 0 @@ -531,14 +534,38 @@ fetch_dzq(){ curl -Ls "$url" > "$file" logger INFO "Updated DZQ to sha '$sha'" } +fetch_icons(){ + res=( + "16" + "24" + "32" + "48" + "64" + "96" + "128" + "256" + ) + url="$stable_url/images/icons" + for i in "${res[@]}"; do + size="${i}x${i}" + dir="$HOME/.local/share/icons/hicolor/$size/apps" + icon="$dir/$app_name.png" + [[ -f $icon ]] && return + if [[ ! -d $dir ]]; then + mkdir -p "$dir" + fi + logger INFO "Updating $size Freedesktop icon" + curl -Ls "${url}/${i}.png" > "$icon" + done +} fetch_helpers_by_sum(){ [[ -f "$config_file" ]] && source "$config_file" declare -A sums sums=( - ["ui.py"]="c62e84ddd1457b71a85ad21da662b9af" + ["ui.py"]="b5e27858e4aaf966067d452f7e44b9eb" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="5ebf7c9694c9ec8df00f0b30871eeb38" + ["funcs"]="44eca80b207057423c2d298cc7cf1e29" ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" @@ -602,6 +629,8 @@ fetch_helpers(){ fetch_geo_file fetch_helpers_by_sum [[ ! -f $share_path/icon.png ]] && freedesktop_dirs + #TODO: integration test + #fetch_icons } raise_error_and_quit(){ local msg="$1" @@ -896,7 +925,7 @@ uninstall(){ } main(){ local zenv=$(zenity --version 2>/dev/null) - [[ -z $zenv ]] && { echo "Requires zenity <= 3.44.1"; exit 1; } + [[ -z $zenv ]] && { echo "Requires zenity >= ${deps[$steamsafe_zenity]}"; exit 1; } if [[ $1 == "--uninstall" ]] || [[ $1 == "-u" ]]; then uninstall && exit 0 diff --git a/helpers/funcs b/helpers/funcs index 9d9c3a9..7d19b29 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -o pipefail -version=5.2.3 +version=5.3.3 #CONSTANTS aid=221100 @@ -978,6 +978,7 @@ generate_log(){ cat <<-DOC > $system_log Distro: $(< /etc/os-release grep -w NAME | awk -F\" '{print $2}') Kernel: $(uname -mrs) + CPU: $(< /proc/cpuinfo awk -F": " '/model name/ {print $2; exit}') Version: $version Branch: $branch Mode: $(if [[ -z $debug ]]; then echo normal; else echo debug; fi) diff --git a/helpers/ui.py b/helpers/ui.py index d988fd0..74e6113 100644 --- a/helpers/ui.py +++ b/helpers/ui.py @@ -19,7 +19,7 @@ gi.require_version("Gtk", "3.0") from gi.repository import Gtk, GLib, Gdk, GObject, Pango from enum import Enum -# 5.2.3 +# 5.3.3 app_name = "DZGUI" start_time = 0 diff --git a/images/icons/128.png b/images/icons/128.png new file mode 100644 index 0000000000000000000000000000000000000000..b6aed5c1196ccf42fc84a44c83e6883c28d82b3c GIT binary patch literal 32867 zcmV*FKx)5
=P4Gl9W_xAdo^SmcuL7C>p(7xp)=q6^34Jl`*QY
z)N+7WC5k8_c(rs~loAm|OT-QmG65kGNV1LoG+(ou)z0?*G50x{P#F<9P@H4LI1%TZ
zSl`}j&GpXrectDJUcq6#@e6*vSgqGL+R1;}LaX22+3DA4B^HE$1x{BpcI^bErqTs3
zeC#&o+n&{`LI}a>qCv{Qkrp@yFHN3JH?Uq-?AnQ2%?wkO-0Me@k`z%A6wDU|xWv_V
zVC*K6(o{xbjG`$uO(ob*5-lZ9J#xzBe$RYa(NqPSZldo-&M$V{e)) hFNTF#*$GomsuNp`K
zsRUhX>2?|P8Aglu0Xqf=fpK!AM82Mjq$CL5b5xhu$>sYYpzj8>Rv0PscTeB}V>G&`
z3rZ2uT5@^W5)mYk|KDNs#3-1T0vSEsXwgdGU0^O1)_I(FH0u>cNbF$gM~9pOdutI!
zBaDIQNIri+5D1`}Y1Zo_PS Oab#Q~jW&FoMutO=))J`{DHrB>;r2K%&nq9ECdP3kr$T$|ICX}X_cyp@#x{l+
zLP0W1q5otAf3>*fUo4UTC>Q?q|Mh?Se^~#&J>Tj-?_d1If9t>6eD#n1{yzi$gA&94
z>@>9h{;RvgZ&vT`Q!ci|AVf|y)*^)<0a+J@eb2BPNGYL*mbPyR^TN>g$dtLBN0!Oe
z3!e)yWn|GjJYG3pMox|4#bM9G!GQ)E8HmbsoP-Dwk@p4D
$tf%;{WsYU;nB}UyP9-fA4$w3xD-5b8p`wD+5B{
zx}3}sBDz$VW`-Rc>>a_{kAqPul0@S4c+Jsj^@`syrNqAN@D6-$nf4Z4Xr|V(7i5DB
zkwv?5S@P0V$HNaVsY{rwWw~l-9?Q(?%S(rlkuD_852Tj2ykXAb$(oPdc37M6KC$md
zM6I}dVd8YDSuP9oOSdn1_>nccb_YgN&1>x782g^%N3T(?8g%s<0142yj=^RU1TrT=
zi5&XVK~tEtL{tT-)c;rD=$Eadqa!L~ppg{I28BWifo&)HX+RQ@8oJJ6$LWDTph^NK
z2SlkTJ*;LmJL_4U9`Q&1yWhiadab1IBOl?<{DnWy&%E&5gSkReH=aV|4aUbEYh6483nl>PtW;2s!Eh?qU?Q_6^55+Ky8hZG?MO
0NT+wL8S$6J1)2qEPzR=i~+HDaY*%O-Z9A)v)T
z3WbM@=piE~eR8FD#X`rxyJ*6$5bm6yLqI%?=ZPgPND#`^hAiurS-)Iyr-`;0s@Cpy
zDy82zQoA)v-3%oQp8C34Q)#Id8cM|v1AdJ7ek5GS4m3C86DpnW-wX-V0&yZvfpHhO
zL|LnmNHhjJp`D8MIB`8B$RpwFju9{gL-D+W`*vjH^t0HC_VCsEK!|nu#t#vyM^;a{
zZ(M$eJpDM4H@N=g&USr>c
WDcbD>bpMxq!nik&_Qi9ERS
%sEzQzV=N%|TlV+Il-WI9#dJRC>bNN81nRSuGDJrqkpwKuTLB
zgy)ORnRiCb-flebf<1}Zx9;B8?r@`=Ms({EC3Qau;Hvh7#vY{gpG~)o_VX8>|M-qi
zzg=O9Xl@h%T?;N-=C8FcaD}D?KX`*i)v5|NdTQ-|Z|^PdSCe)f-#x?b3$*v>wFzK$
zGXT?f@5#4?x)_0DKA$Mjv-PgxaGnt--2d_$TJ@Oc`(4d_lzETQa_tq+ey~o@7yNl3
zxPrSxsEymb(1NFAwQ>=MI!FDwSn1o>!mFX5d2Kjn1X1;JY$(RAVv
+Z>mtPlK%+Ur+eehK6_n^UDIn`@m6}ZC0Rmz@Z@^tA39O-
z&57_I&PI*$4j&xjWir8~T8(DDi#uuW&+iPI(x_$atei%^+Axat!Ob0w+$qx%>=em7
zK-=*1NX_MupdHk0TgJ9!n|2xpv|8^Y?;8 4IWT=|&;RC$erfLhsmzU)}