a2qlinux 0.5.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/CHANGELOG.md +34 -0
  2. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/PKG-INFO +3 -3
  3. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/README.md +2 -2
  4. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/__init__.py +12 -0
  5. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/_version.py +2 -2
  6. a2qlinux-0.7.0/a2qlinux/bin/questlog_ctl.exe +0 -0
  7. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/bin/wpcap.dll +0 -0
  8. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/desktop.py +2 -3
  9. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/diagnose.py +73 -5
  10. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/launcher.py +150 -4
  11. a2qlinux-0.7.0/a2qlinux/open_folders.py +123 -0
  12. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/setup_desktop.py +126 -26
  13. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/steam.py +2 -1
  14. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/tray.py +4 -7
  15. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/bridge/build.sh +2 -2
  16. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/bridge/questlog_ctl.c +121 -1
  17. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/docs/ARCHITECTURE.md +258 -13
  18. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/docs/INSTALL.md +19 -11
  19. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/docs/RELEASE.md +14 -2
  20. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/docs/TROUBLESHOOTING.md +14 -4
  21. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/docs/UPDATING.md +2 -2
  22. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/docs/USING.md +69 -6
  23. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_diagnose.py +54 -0
  24. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_launcher.py +91 -0
  25. a2qlinux-0.7.0/tests/test_open_folders.py +167 -0
  26. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_setup_desktop.py +89 -5
  27. a2qlinux-0.5.0/a2qlinux/bin/questlog_ctl.exe +0 -0
  28. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/.gitignore +0 -0
  29. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/LICENSE +0 -0
  30. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/config.py +0 -0
  31. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/kde_overlays.py +0 -0
  32. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/pcap_bridge.py +0 -0
  33. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/a2qlinux/update.py +0 -0
  34. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/bridge/tests/bridge_client_test.c +0 -0
  35. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/bridge/tests/zorder_guard_test.c +0 -0
  36. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/bridge/wpcap_bridge.c +0 -0
  37. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/docs/README.md +0 -0
  38. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/pyproject.toml +0 -0
  39. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/__init__.py +0 -0
  40. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_config.py +0 -0
  41. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_desktop.py +0 -0
  42. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_kde_overlays.py +0 -0
  43. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_pcap_bridge.py +0 -0
  44. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_replay_stream.py +0 -0
  45. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_steam.py +0 -0
  46. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_update.py +0 -0
  47. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tests/test_version.py +0 -0
  48. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tools/__init__.py +0 -0
  49. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tools/pcap2questlog.py +0 -0
  50. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tools/replay_stream.py +0 -0
  51. {a2qlinux-0.5.0 → a2qlinux-0.7.0}/tools/tcp_owner_probe.c +0 -0
@@ -3,6 +3,40 @@
3
3
  What changed for players, release by release. Technical details are in
4
4
  `docs/ARCHITECTURE.md`.
5
5
 
6
+ ## [0.7.0] — 2026-11-13
7
+
8
+ ### Changed
9
+ - After updating, run `a2qlinux-setup` once and answer yes to its
10
+ question about Questlog's Open Folder buttons; without that step they
11
+ keep showing Wine's error (see Fixed below).
12
+ - `a2qlinux --diagnose` (and so the problem report) also names the
13
+ distribution, the kernel, the desktop with its version, Wayland or X11,
14
+ and the Proton the game last ran with, so a report shows on which
15
+ system a problem happened.
16
+
17
+ ### Fixed
18
+ - Questlog's **Open Folder** buttons (for example the recordings in the
19
+ Combat Meter) open the folder in the desktop's file manager instead of
20
+ showing "There is no Windows program configured to open this type of
21
+ file". `a2qlinux-setup` explains the fix and asks first; it adds one
22
+ entry to the game's Proton environment, and
23
+ `a2qlinux-setup --no-open-folders` takes it back out.
24
+
25
+ ## [0.6.0] — 2026-11-12
26
+
27
+ ### Changed
28
+ - The menu entry, the desktop shortcut and the tray icon are called
29
+ **A2Qlinux** instead of "Questlog (AION 2)", and their icon is Questlog's
30
+ Q in red, so they are told apart from Questlog's own icon. Searching the
31
+ menu for "Questlog" still finds the entry. Existing entries are renamed
32
+ on the next start, keeping any options added to them by hand.
33
+
34
+ ### Fixed
35
+ - A Questlog that gets stuck while starting (its window stays empty and it
36
+ counts no fights, because of a rare fault in Wine) is noticed, usually
37
+ within a few seconds, ended and started again, without touching the game.
38
+ Only if the second start gets stuck too does A2Qlinux stop and say so.
39
+
6
40
  ## [0.5.0] — 2026-11-10
7
41
 
8
42
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: a2qlinux
3
- Version: 0.5.0
3
+ Version: 0.7.0
4
4
  Summary: Questlog Desktop (AION 2 damage meter) on Linux under Proton, with live game traffic.
5
5
  Project-URL: homepage, https://github.com/raman78/A2Qlinux
6
6
  Project-URL: repository, https://github.com/raman78/A2Qlinux
@@ -89,7 +89,7 @@ for Arch, Debian, Ubuntu, Fedora and openSUSE. In short:
89
89
  `a2qlinux-setup --desktop-shortcut`. It installs Questlog, checks
90
90
  everything else and prints the command for anything still missing — see
91
91
  [Installing A2Qlinux and Questlog](https://github.com/raman78/A2Qlinux/blob/main/docs/INSTALL.md#installing-a2qlinux-and-questlog).
92
- 4. Start **Questlog (AION 2)** from the menu, or set the Steam launch option
92
+ 4. Start **A2Qlinux** from the menu, or set the Steam launch option
93
93
  that `a2qlinux-setup` prints (it says when the option is already set).
94
94
 
95
95
  ## Documentation
@@ -132,7 +132,7 @@ the repository. Releasing:
132
132
  A2Qlinux is an independent project, not made or endorsed by Questlog's
133
133
  authors or by AION 2's publisher. It contains no Questlog code or assets:
134
134
  Questlog is downloaded from its authors, and its icon is taken from your own
135
- installation. Questlog and its name belong to its authors (questlog.gg).
135
+ installation (and its Q coloured red, for A2Qlinux's menu entry and tray icon). Questlog and its name belong to its authors (questlog.gg).
136
136
 
137
137
  Whether third-party meters are allowed is for the game's publisher, NCSOFT,
138
138
  to decide. It has not said so either way, and its rules forbid
@@ -47,7 +47,7 @@ for Arch, Debian, Ubuntu, Fedora and openSUSE. In short:
47
47
  `a2qlinux-setup --desktop-shortcut`. It installs Questlog, checks
48
48
  everything else and prints the command for anything still missing — see
49
49
  [Installing A2Qlinux and Questlog](https://github.com/raman78/A2Qlinux/blob/main/docs/INSTALL.md#installing-a2qlinux-and-questlog).
50
- 4. Start **Questlog (AION 2)** from the menu, or set the Steam launch option
50
+ 4. Start **A2Qlinux** from the menu, or set the Steam launch option
51
51
  that `a2qlinux-setup` prints (it says when the option is already set).
52
52
 
53
53
  ## Documentation
@@ -90,7 +90,7 @@ the repository. Releasing:
90
90
  A2Qlinux is an independent project, not made or endorsed by Questlog's
91
91
  authors or by AION 2's publisher. It contains no Questlog code or assets:
92
92
  Questlog is downloaded from its authors, and its icon is taken from your own
93
- installation. Questlog and its name belong to its authors (questlog.gg).
93
+ installation (and its Q coloured red, for A2Qlinux's menu entry and tray icon). Questlog and its name belong to its authors (questlog.gg).
94
94
 
95
95
  Whether third-party meters are allowed is for the game's publisher, NCSOFT,
96
96
  to decide. It has not said so either way, and its rules forbid
@@ -28,3 +28,15 @@ def shown_version(root=None):
28
28
  reason = (done.stderr.strip().splitlines() or [f"exit code {done.returncode}"])[0]
29
29
  return f"{__version__} (source checkout; git describe failed: {reason})"
30
30
  return f"{done.stdout.strip().removeprefix('v')} (source checkout)"
31
+
32
+
33
+ def _icon_path():
34
+ from pathlib import Path
35
+ return Path.home() / ".local" / "share" / "icons" / "a2qlinux.png"
36
+
37
+
38
+ # What the menu entry, the tray icon and the notifications are called and show.
39
+ # The icon is Questlog's own, recoloured on the player's computer by
40
+ # a2qlinux-setup (setup_desktop.a2qlinux_icon); A2Qlinux does not ship it.
41
+ APP_NAME = "A2Qlinux"
42
+ ICON = _icon_path()
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.5.0'
22
- __version_tuple__ = version_tuple = (0, 5, 0)
21
+ __version__ = version = '0.7.0'
22
+ __version_tuple__ = version_tuple = (0, 7, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -23,6 +23,7 @@ import subprocess
23
23
  import sys
24
24
  import time
25
25
 
26
+ from . import APP_NAME, ICON
26
27
  from .config import questlog_dir
27
28
 
28
29
  LOCK = questlog_dir() / "proton-stream" / ".lock"
@@ -102,9 +103,7 @@ def ask_running_launcher(game_starting):
102
103
 
103
104
 
104
105
  def notify(text):
105
- subprocess.run(["notify-send", "--app-name=Questlog (AION 2)",
106
- "--icon=" + str(Path.home() / ".local/share/icons/questlog-aion2.png"),
107
- "Questlog (AION 2)", text], check=False)
106
+ subprocess.run(["notify-send", f"--app-name={APP_NAME}", f"--icon={ICON}", APP_NAME, text], check=False)
108
107
 
109
108
 
110
109
  def main():
@@ -3,14 +3,18 @@
3
3
  Read only: it changes nothing, so it is safe at any time, the game running or
4
4
  not. Each check gives one line: fine, a note, or a problem with what to do.
5
5
 
6
- 1. A2Qlinux's version, the settings file, Questlog's folder and version.
6
+ 1. A2Qlinux's version, the system (distribution, kernel, desktop and its
7
+ session type), the settings file, Questlog's folder and version.
7
8
  2. The checks a2qlinux-setup makes: programs, capture permission, the tray
8
9
  icon, the Windows parts (the same functions, a2qlinux.setup_desktop).
9
- 3. Steam: a native installation, the game's prefix, our wpcap.dll in it.
10
+ 3. Steam: a native installation, the game's prefix, the Proton that last
11
+ ran it, our wpcap.dll in it.
10
12
  4. AION 2's Steam launch option, read from each Steam account's
11
13
  localconfig.vdf, and whether it ever ran (steam_launch.log).
12
14
  5. What runs now: the launcher, Questlog (fed by the bridge or not), the game.
13
15
  6. On KDE Plasma 6, whether the KDE overlays are set up.
16
+ 7. Whether the game's prefix has a command for Questlog's Open Folder
17
+ buttons, read from its system.reg (no Wine is started).
14
18
 
15
19
  With --report it also writes a report file: the diagnosis and the end of
16
20
  launcher.log, with the home folder, user name, Steam account numbers and
@@ -23,6 +27,7 @@ sent by this program.
23
27
  import ipaddress
24
28
  import os
25
29
  from pathlib import Path
30
+ import platform
26
31
  import re
27
32
  import shutil
28
33
  import socket
@@ -121,6 +126,44 @@ def judge_launch_option(option, ours):
121
126
 
122
127
  # ---------------------------------------------------------------- checks
123
128
 
129
+ DESKTOP_VERSION = {"KDE": ["plasmashell", "--version"], "GNOME": ["gnome-shell", "--version"]}
130
+ VERSION_WAIT = 5 # s for a desktop's --version
131
+
132
+
133
+ def system_lines(env=os.environ, os_info=None, kernel=None, run=subprocess.run):
134
+ """[(OK, text)]: the distribution, the kernel, the desktop with its version where it says, the session type."""
135
+ from .setup_desktop import os_release
136
+ info = os_release() if os_info is None else os_info
137
+ distro = info.get("PRETTY_NAME") or " ".join(filter(None, (info.get("NAME"), info.get("VERSION_ID"))))
138
+ desktop = env.get("XDG_CURRENT_DESKTOP") or env.get("DESKTOP_SESSION") or "unknown (no XDG_CURRENT_DESKTOP)"
139
+ version = ""
140
+ for name, command in DESKTOP_VERSION.items():
141
+ if name in desktop.upper().split(":") and shutil.which(command[0]):
142
+ try:
143
+ done = run(command, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=VERSION_WAIT)
144
+ version = done.stdout.strip().splitlines()[0] if done.stdout.strip() else ""
145
+ except (OSError, subprocess.TimeoutExpired):
146
+ version = ""
147
+ break
148
+ session = env.get("XDG_SESSION_TYPE") or "unknown session type"
149
+ return [(OK, f"System: {distro or 'unknown distribution (no /etc/os-release)'}, "
150
+ f"kernel {kernel or platform.release()}"),
151
+ (OK, f"Desktop: {desktop}{f' ({version})' if version else ''}, {session}")]
152
+
153
+
154
+ def proton_line(prefix):
155
+ """(level, text): the Proton that last ran the prefix, from its config_info (Proton writes it on each start)."""
156
+ try:
157
+ lines = (Path(prefix).parent / "config_info").read_text(errors="replace").splitlines()
158
+ except OSError:
159
+ return NOTE, "Proton: unknown (no config_info next to the prefix; the game not started yet?)"
160
+ version = lines[0].strip() if lines else ""
161
+ tool = next((part for line in lines[1:] for part in [line.split("/files/", 1)[0].rsplit("/", 1)[-1]]
162
+ if "/files/" in line), "")
163
+ if not version:
164
+ return NOTE, "Proton: unknown (config_info is empty)"
165
+ return OK, f"Proton (last run): {version}" + (f" ({tool})" if tool else "")
166
+
124
167
  def check_setup(results):
125
168
  from . import setup_desktop as setup
126
169
  info = setup.os_release()
@@ -153,6 +196,7 @@ def check_steam(results, appid, qdir):
153
196
  try:
154
197
  prefix = launcher.game_prefix(appid, roots)
155
198
  results.append((OK, f"Game prefix: {prefix}"))
199
+ results.append(proton_line(prefix))
156
200
  dll = prefix / "drive_c" / "windows" / "system32" / "Npcap" / "wpcap.dll"
157
201
  try:
158
202
  ours = launcher.BRIDGE_SIGNATURE in dll.read_bytes()
@@ -201,7 +245,7 @@ def check_running(results, appid):
201
245
  if not fed:
202
246
  results.append((PROBLEM, "Now: Questlog runs, but was not started by A2Qlinux: it gets no game "
203
247
  "traffic, and the game waits until it is closed. Quit it from its own tray "
204
- "icon and start 'Questlog (AION 2)' from the menu"))
248
+ "icon and start 'A2Qlinux' from the menu"))
205
249
  elif not running:
206
250
  results.append((PROBLEM, "Now: Questlog runs with the bridge, but A2Qlinux has ended (status "
207
251
  "window closed?): it gets no game traffic. Quit it and start it again"))
@@ -223,18 +267,42 @@ def check_kde(results):
223
267
  "(a2qlinux-setup --kde-overlays)"))
224
268
 
225
269
 
270
+ def check_open_folders(results, appid, prefix=None):
271
+ from . import launcher, open_folders
272
+ try:
273
+ prefix = prefix or launcher.game_prefix(appid)
274
+ except RuntimeError:
275
+ return # reported by check_steam
276
+ state, value = open_folders.registry_state(prefix / "system.reg")
277
+ if state == "ours":
278
+ results.append((OK, "Open Folder: set up; Questlog's folders open in the file manager"))
279
+ elif state == "other":
280
+ results.append((NOTE, f"Open Folder: the prefix has another command for opening folders "
281
+ f"({value or 'a key without a command'}); A2Qlinux leaves it as it is"))
282
+ else:
283
+ results.append((NOTE, "Open Folder: not set up; Questlog's Open Folder buttons show Wine's \"no Windows "
284
+ "program configured\" (a2qlinux-setup --open-folders; a change made in the last "
285
+ "30 s may not be saved to the prefix yet)"))
286
+
287
+
226
288
  def diagnose(appid=3393110):
227
289
  """[(level, text)], in the order of the module docstring."""
228
290
  settings, problems = config.load()
229
291
  qdir = settings.questlog_dir.expanduser()
230
- results = [(OK, f"A2Qlinux {shown_version()}"), (OK, f"Settings: {config.CONFIG_PATH}")]
292
+ results = [(OK, f"A2Qlinux {shown_version()}")]
293
+ try:
294
+ results += system_lines()
295
+ except Exception as error: # as below: reported, never hiding the rest
296
+ results.append((PROBLEM, f"This check failed: {error!r} (please report it)"))
297
+ results.append((OK, f"Settings: {config.CONFIG_PATH}"))
231
298
  results += [(PROBLEM, f"Settings: {p}") for p in problems]
232
299
  if (qdir / "Questlog.exe").is_file():
233
300
  from .update import installed_version
234
301
  results.append((OK, f"Questlog: {installed_version(qdir) or 'version unreadable'} in {qdir}"))
235
302
  else:
236
303
  results.append((PROBLEM, f"Questlog: no Questlog.exe in {qdir}; run a2qlinux-setup"))
237
- for check in (check_setup, lambda r: check_steam(r, appid, qdir), lambda r: check_running(r, appid), check_kde):
304
+ for check in (check_setup, lambda r: check_steam(r, appid, qdir), lambda r: check_running(r, appid), check_kde,
305
+ lambda r: check_open_folders(r, appid)):
238
306
  try:
239
307
  check(results)
240
308
  except Exception as error: # one broken check must not hide the others; it is reported
@@ -39,7 +39,7 @@ import sys
39
39
  import threading
40
40
  import time
41
41
 
42
- from . import config, shown_version
42
+ from . import APP_NAME, ICON, config, shown_version
43
43
  from . import update as questlog_update
44
44
  from .pcap_bridge import BridgeServer, read_records
45
45
 
@@ -803,9 +803,7 @@ UPDATE_TRIAL = 60 # s: a just-updated Questlog that exits sooner i
803
803
 
804
804
  def notify(text):
805
805
  """Desktop notification, for what the user should know even with the terminal hidden."""
806
- subprocess.run(["notify-send", "--app-name=Questlog (AION 2)",
807
- "--icon=" + str(Path.home() / ".local/share/icons/questlog-aion2.png"),
808
- "Questlog (AION 2)", text], check=False)
806
+ subprocess.run(["notify-send", f"--app-name={APP_NAME}", f"--icon={ICON}", APP_NAME, text], check=False)
809
807
 
810
808
 
811
809
  def check_for_updates(questlog_dir, state_dir):
@@ -1095,6 +1093,125 @@ class QuestlogLaunch:
1095
1093
  return self.returncode
1096
1094
 
1097
1095
 
1096
+ START_WAIT = 30 # s for a started Questlog to start its first own process (1 s when measured)
1097
+ STUCK_WAIT = 3 # s a stuck copy of Questlog's main process must last to count as a hang
1098
+ START_ATTEMPTS = 2 # starts in a row that may hang before the launcher gives up
1099
+
1100
+
1101
+ def questlog_process_states():
1102
+ """Questlog's processes in the game prefix, as (pid, helper, threads) each.
1103
+
1104
+ helper: Chromium's own processes (GPU, renderers, utilities) carry
1105
+ `--type=` on their command line. Questlog's main process does not, nor
1106
+ does a copy of it that Wine has forked to start a new process but that
1107
+ has not yet become that program - which has a single thread.
1108
+ """
1109
+ states = []
1110
+ for pid in game_processes(APPID, ["questlog.exe"])["questlog.exe"]:
1111
+ helper = "\0--type=" in _read(f"/proc/{pid}/cmdline", 4096)
1112
+ threads = next((int(line.split(":", 1)[1]) for line in _read(f"/proc/{pid}/status").splitlines()
1113
+ if line.startswith("Threads:")), 0)
1114
+ states.append((pid, helper, threads))
1115
+ return states
1116
+
1117
+
1118
+ def stuck_copies(states):
1119
+ """PIDs that look like a forked copy of Questlog's main process: no `--type=`, one thread.
1120
+
1121
+ Only beside a main process with threads of its own, so that a main
1122
+ process that has not started its threads yet is never taken for one.
1123
+ """
1124
+ if not any(not helper and threads > 1 for _, helper, threads in states):
1125
+ return set()
1126
+ return {pid for pid, helper, threads in states if not helper and threads == 1}
1127
+
1128
+
1129
+ class StartWatch:
1130
+ """Whether a started Questlog came up, or hung at its start (§6.9).
1131
+
1132
+ A healthy Questlog starts its GPU process about a second after its main
1133
+ process appears, and its other processes right after. Once Wine's start
1134
+ of that first process hung - the forked copy stuck in libc's environment
1135
+ lock before it could become the new program - and Questlog waited for it
1136
+ for ever, with no window and no capture. check() answers once per start:
1137
+ "up" when any of Questlog's own processes is there; "retry" when the same
1138
+ stuck copy has lasted `stuck_wait` seconds (a copy lives for a fraction
1139
+ of a second normally), or when none of Questlog's own processes came
1140
+ within `wait` seconds of its main process (some other hang, or a very
1141
+ slow start: hence the long wait); "give-up" instead of "retry" once that
1142
+ has happened `attempts` times in a row.
1143
+ """
1144
+
1145
+ def __init__(self, wait=START_WAIT, stuck_wait=STUCK_WAIT, attempts=START_ATTEMPTS):
1146
+ self.wait = wait
1147
+ self.stuck_wait = stuck_wait
1148
+ self.attempts = attempts
1149
+ self.hung = 0 # hung starts in a row
1150
+ self.watching = False
1151
+ self.main_since = None
1152
+ self.stuck_since = {} # PID of a stuck-looking copy -> when it was first seen
1153
+ self.hidden = False # how the watched start was made, for its retry
1154
+
1155
+ def started(self, hidden=False):
1156
+ self.watching = True
1157
+ self.main_since = None
1158
+ self.stuck_since = {}
1159
+ self.hidden = hidden
1160
+
1161
+ def check(self, processes, now):
1162
+ if not self.watching:
1163
+ return None
1164
+ if any(helper for _, helper, _ in processes):
1165
+ self.watching = False
1166
+ self.hung = 0
1167
+ return "up"
1168
+ if not processes: # not there yet (the Wine session coming up), or gone
1169
+ self.main_since = None
1170
+ self.stuck_since = {}
1171
+ return None
1172
+ if self.main_since is None:
1173
+ self.main_since = now
1174
+ stuck = stuck_copies(processes)
1175
+ self.stuck_since = {pid: self.stuck_since.get(pid, now) for pid in stuck}
1176
+ if now - self.main_since < self.wait \
1177
+ and not any(now - since >= self.stuck_wait for since in self.stuck_since.values()):
1178
+ return None
1179
+ self.watching = False
1180
+ self.hung += 1
1181
+ return "retry" if self.hung < self.attempts else "give-up"
1182
+
1183
+
1184
+ HUNG_END_WAIT = 5 # s for a hung Questlog's processes to go after SIGTERM, before SIGKILL
1185
+
1186
+
1187
+ def end_hung_questlog():
1188
+ """End a Questlog that hung at its start: SIGTERM to all its processes, SIGKILL after HUNG_END_WAIT.
1189
+
1190
+ It has not got to any game data yet, so nothing is waiting to be saved,
1191
+ and the session end of §6.4 is no use here: sent to a Questlog still
1192
+ starting, it was ignored for the whole QUESTLOG_QUIT_WAIT (measured).
1193
+ Questlog only (I2): the game's session is held by Questlog's launch (§5.1).
1194
+ """
1195
+ def signal_all(signum):
1196
+ pids = game_processes(APPID, ["questlog.exe"])["questlog.exe"]
1197
+ for pid in pids:
1198
+ try:
1199
+ os.kill(pid, signum)
1200
+ except ProcessLookupError:
1201
+ pass
1202
+ return pids
1203
+
1204
+ ended = signal_all(signal.SIGTERM)
1205
+ deadline = time.monotonic() + HUNG_END_WAIT
1206
+ while time.monotonic() < deadline:
1207
+ if not game_processes(APPID, ["questlog.exe"])["questlog.exe"]:
1208
+ log(f"Questlog's {len(ended)} process(es) ended.")
1209
+ return
1210
+ time.sleep(0.2)
1211
+ left = signal_all(signal.SIGKILL)
1212
+ log(f"{len(left)} of Questlog's processes were still there {HUNG_END_WAIT} s after SIGTERM; killed them.")
1213
+
1214
+
1098
1215
  def launch_questlog(executable, server, protontricks, log_path, hidden=False, hold_session=True):
1099
1216
  """Start Questlog in the game prefix; a QuestlogLaunch (hold_session) or the bare launch.
1100
1217
 
@@ -1213,6 +1330,7 @@ def main():
1213
1330
  quit_control = QuitControl()
1214
1331
 
1215
1332
  trial = {"until": 0.0} # end of a just-installed update's trial run
1333
+ start_watch = StartWatch()
1216
1334
 
1217
1335
  def start_questlog(hidden=False):
1218
1336
  # A fresh Questlog shows its window (unless hidden); earlier "open" requests are answered by that.
@@ -1222,6 +1340,7 @@ def main():
1222
1340
  trial["until"] = time.monotonic() + UPDATE_TRIAL
1223
1341
  log(f"Starting Questlog {questlog_update.installed_version(executable.parent) or '(version unknown)'}.")
1224
1342
  started = launch_questlog(executable, server, protontricks, log_path, hidden=hidden)
1343
+ start_watch.started(hidden)
1225
1344
  tray.start()
1226
1345
  hide_questlog_tray_icon(protontricks, log_path)
1227
1346
  return started
@@ -1251,6 +1370,33 @@ def main():
1251
1370
  questlog = start_questlog()
1252
1371
  continue
1253
1372
  break
1373
+ if not quit_control.quitting and start_watch.watching:
1374
+ states = questlog_process_states()
1375
+ verdict = start_watch.check(states, time.monotonic())
1376
+ if verdict in ("retry", "give-up"):
1377
+ stuck = sorted(stuck_copies(states))
1378
+ how = (f"Wine's start of its first own process hung (stuck process "
1379
+ f"{', '.join(map(str, stuck))})" if stuck else
1380
+ f"none of its own processes followed within {START_WAIT} s")
1381
+ if verdict == "retry":
1382
+ log(f"Questlog hung at its start: {how}. Ending it and starting it again.")
1383
+ else:
1384
+ log(f"Questlog hung at its start again ({START_ATTEMPTS} starts in a row): {how}. "
1385
+ "Ending it; start A2Qlinux again from the menu. If this keeps happening, "
1386
+ "file a problem report (a2qlinux --diagnose --report).")
1387
+ tray.stop()
1388
+ end_hung_questlog()
1389
+ try:
1390
+ questlog.wait(timeout=30)
1391
+ except subprocess.TimeoutExpired:
1392
+ log("The previous Questlog launcher did not end; continuing anyway.")
1393
+ if verdict == "give-up":
1394
+ notify(f"Questlog hung at its start {START_ATTEMPTS} times in a row and was ended. "
1395
+ "Start A2Qlinux again from the menu; details in the A2Qlinux window.")
1396
+ return 1
1397
+ questlog = start_questlog(hidden=start_watch.hidden)
1398
+ told = False
1399
+ continue
1254
1400
  for request in requests.take():
1255
1401
  if request == "tray-died":
1256
1402
  log("Showing Questlog's own tray icon again, so it can still be quit.")
@@ -0,0 +1,123 @@
1
+ """Questlog's "Open Folder" buttons: a handler for opening folders in the game's prefix (docs/ARCHITECTURE.md §6.10).
2
+
3
+ Questlog opens a folder (Combat Meter > Recordings > Open Folder) with
4
+ Electron's shell.openPath, which asks Windows for the verb "explore" of the
5
+ class "folder". Wine's prefix has no command for that verb, so Wine shows
6
+ "There is no Windows program configured to open this type of file" instead.
7
+
8
+ a2qlinux-setup offers to add the one missing command,
9
+ HKLM\\Software\\Classes\\folder\\shell\\explore\\command, set to Wine's
10
+ winebrowser.exe - what the prefix already uses for web links - which hands
11
+ the folder to xdg-open, so it opens in the desktop's file manager. The
12
+ registry is read and written by questlog_ctl.exe (`folder-handler`) inside
13
+ the prefix, so the live registry is what is checked, also while the game
14
+ runs. A command that someone else put there is never changed or removed.
15
+ `a2qlinux --diagnose` only reads: it looks the key up in the prefix's
16
+ system.reg (registry_state) and starts no Wine.
17
+ """
18
+
19
+ from pathlib import Path
20
+ import re
21
+ import shutil
22
+ import subprocess
23
+
24
+ APPID = 3393110
25
+ CTL_WAIT = 120 # s for protontricks-launch to start Wine and questlog_ctl.exe to answer
26
+ HANDLER_KEY = r"Software\\Classes\\folder\\shell\\explore\\command" # as system.reg spells it
27
+ HANDLER_VALUE = r'"C:\windows\system32\winebrowser.exe" "%1"' # what questlog_ctl.exe writes
28
+ OUTCOMES = ("absent", "ours", "other", "set", "removed", "error")
29
+
30
+ EXPLANATION = """\
31
+ Questlog's "Open Folder" buttons (for example under Combat Meter > Recordings)
32
+ need a program that opens folders, and AION 2's Wine prefix has none for them,
33
+ so Questlog shows "There is no Windows program configured to open this type of
34
+ file". A2Qlinux can add that one missing entry to the prefix's registry; the
35
+ folder then opens in your desktop's file manager. Nothing that works already
36
+ changes; `a2qlinux-setup --no-open-folders` removes the entry again."""
37
+
38
+
39
+ def registry_state(system_reg):
40
+ """("absent" | "ours" | "other", value or None) from the prefix's system.reg, read as text.
41
+
42
+ The same three answers as questlog_ctl.exe folder-handler status. The
43
+ file is the wineserver's last save: it saves a change about 30 s later
44
+ (26 s measured), so a change made just now may not be in it yet.
45
+ """
46
+ text = Path(system_reg).read_text(encoding="utf-8", errors="replace")
47
+ section = re.search(r"^\[" + re.escape(HANDLER_KEY) + r"\][^\n]*\n(.*?)(?=^\[|\Z)", text,
48
+ re.MULTILINE | re.DOTALL | re.IGNORECASE)
49
+ if not section:
50
+ return "absent", None
51
+ default = re.search(r'^@="((?:[^"\\]|\\.)*)"', section.group(1), re.MULTILINE)
52
+ if not default:
53
+ return "other", None
54
+ value = re.sub(r"\\(.)", r"\1", default.group(1))
55
+ return ("ours" if value == HANDLER_VALUE else "other"), value
56
+
57
+
58
+ def outcome(stdout):
59
+ """(outcome word, the line it came from) from questlog_ctl.exe folder-handler's output; (None, text) if absent."""
60
+ for line in stdout.splitlines():
61
+ word = line.split(":", 1)[0].strip()
62
+ if word in OUTCOMES:
63
+ return word, line.strip()
64
+ return None, stdout.strip()
65
+
66
+
67
+ def run_ctl(action):
68
+ """Run questlog_ctl.exe folder-handler <action> in the game's prefix; (outcome, line).
69
+
70
+ Raises RuntimeError when it cannot be run or gives no answer.
71
+ """
72
+ from .launcher import CTL
73
+ protontricks = shutil.which("protontricks-launch")
74
+ if not protontricks:
75
+ raise RuntimeError("protontricks-launch is not installed (see 'missing' above)")
76
+ if not CTL.is_file():
77
+ raise RuntimeError(f"{CTL} is missing")
78
+ try:
79
+ done = subprocess.run([protontricks, "--appid", str(APPID), str(CTL), "folder-handler", action],
80
+ stdin=subprocess.DEVNULL, capture_output=True, text=True, errors="replace",
81
+ timeout=CTL_WAIT, start_new_session=True)
82
+ except subprocess.TimeoutExpired:
83
+ raise RuntimeError(f"questlog_ctl.exe did not answer within {CTL_WAIT} s") from None
84
+ word, line = outcome(done.stdout)
85
+ if word is None or word == "error":
86
+ tail = [text.strip() for text in done.stderr.splitlines() if text.strip()][-2:]
87
+ raise RuntimeError(f"questlog_ctl.exe folder-handler {action} failed (exit code {done.returncode}): "
88
+ + " / ".join(([line] if line else []) + tail or ["no output"]))
89
+ return word, line
90
+
91
+
92
+ def setup_step(want, ask, interactive, log=print, ctl=run_ctl):
93
+ """a2qlinux-setup's step. want: True (--open-folders), False (--no-open-folders) or None.
94
+
95
+ Returns a problem to note, or None.
96
+ """
97
+ try:
98
+ if want is False:
99
+ word, line = ctl("remove")
100
+ log(f"Open Folder: {line}")
101
+ return None
102
+ word, line = ctl("status")
103
+ if word == "ours":
104
+ log("Open Folder: Questlog's folders open in the file manager.")
105
+ return None
106
+ if word == "other":
107
+ log(f"Open Folder: the prefix already has a command for opening folders; A2Qlinux leaves it ({line}).")
108
+ return None
109
+ if not want:
110
+ if not interactive:
111
+ log("Open Folder is not set up; to let Questlog's Open Folder buttons work, run "
112
+ "a2qlinux-setup --open-folders")
113
+ return None
114
+ log("\n" + EXPLANATION)
115
+ answer = ask("Set this up now? [Y/n] ").strip().lower()
116
+ if answer not in ("", "y", "yes", "t", "tak"):
117
+ log("Not set up; run a2qlinux-setup --open-folders to do it later.")
118
+ return None
119
+ word, line = ctl("set")
120
+ log(f"Open Folder: {line}")
121
+ return None
122
+ except (OSError, RuntimeError) as error:
123
+ return f"Open Folder: {error}; Questlog's Open Folder buttons keep showing Wine's error"