a2qlinux 0.6.0__tar.gz → 0.7.1__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 (52) hide show
  1. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/CHANGELOG.md +42 -0
  2. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/PKG-INFO +1 -1
  3. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/_version.py +2 -2
  4. a2qlinux-0.7.1/a2qlinux/bin/questlog_ctl.exe +0 -0
  5. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/bin/wpcap.dll +0 -0
  6. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/desktop.py +4 -2
  7. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/diagnose.py +325 -8
  8. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/launcher.py +63 -7
  9. a2qlinux-0.7.1/a2qlinux/open_folders.py +123 -0
  10. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/setup_desktop.py +19 -2
  11. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/bridge/build.sh +2 -2
  12. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/bridge/questlog_ctl.c +121 -1
  13. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/docs/ARCHITECTURE.md +239 -17
  14. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/docs/INSTALL.md +8 -3
  15. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/docs/RELEASE.md +8 -2
  16. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/docs/TROUBLESHOOTING.md +23 -5
  17. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/docs/USING.md +55 -0
  18. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_desktop.py +16 -0
  19. a2qlinux-0.7.1/tests/test_diagnose.py +332 -0
  20. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_launcher.py +89 -0
  21. a2qlinux-0.7.1/tests/test_open_folders.py +167 -0
  22. a2qlinux-0.6.0/a2qlinux/bin/questlog_ctl.exe +0 -0
  23. a2qlinux-0.6.0/tests/test_diagnose.py +0 -111
  24. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/.gitignore +0 -0
  25. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/LICENSE +0 -0
  26. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/README.md +0 -0
  27. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/__init__.py +0 -0
  28. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/config.py +0 -0
  29. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/kde_overlays.py +0 -0
  30. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/pcap_bridge.py +0 -0
  31. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/steam.py +0 -0
  32. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/tray.py +0 -0
  33. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/a2qlinux/update.py +0 -0
  34. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/bridge/tests/bridge_client_test.c +0 -0
  35. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/bridge/tests/zorder_guard_test.c +0 -0
  36. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/bridge/wpcap_bridge.c +0 -0
  37. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/docs/README.md +0 -0
  38. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/docs/UPDATING.md +0 -0
  39. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/pyproject.toml +0 -0
  40. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/__init__.py +0 -0
  41. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_config.py +0 -0
  42. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_kde_overlays.py +0 -0
  43. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_pcap_bridge.py +0 -0
  44. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_replay_stream.py +0 -0
  45. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_setup_desktop.py +0 -0
  46. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_steam.py +0 -0
  47. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_update.py +0 -0
  48. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tests/test_version.py +0 -0
  49. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tools/__init__.py +0 -0
  50. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tools/pcap2questlog.py +0 -0
  51. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tools/replay_stream.py +0 -0
  52. {a2qlinux-0.6.0 → a2qlinux-0.7.1}/tools/tcp_owner_probe.c +0 -0
@@ -3,6 +3,48 @@
3
3
  What changed for players, release by release. Technical details are in
4
4
  `docs/ARCHITECTURE.md`.
5
5
 
6
+ ## [0.7.1] — 2026-11-13
7
+
8
+ ### Fixed
9
+ - Starting **A2Qlinux** again after its status window was closed no longer
10
+ stops with "Questlog is already running and fed by another A2Qlinux".
11
+ The Questlog left behind, which got no game traffic and had no tray icon
12
+ to quit it from, is closed once it has saved, and started again; the
13
+ game keeps running.
14
+ - Clicking the **A2Qlinux** menu entry while A2Qlinux runs from a
15
+ terminal (`a2qlinux-run`) opens Questlog's window, as it does when
16
+ A2Qlinux was started from the menu.
17
+ - The problem report names the exact Proton build the game last ran with
18
+ (for example GE-Proton11-12), not only a version number several builds
19
+ share.
20
+
21
+ ### Changed
22
+ - `a2qlinux --diagnose` also names the graphics card and its driver, the
23
+ screens and their scale, and Proton, Wine or graphics settings made
24
+ outside the game's launch option. The problem report also carries
25
+ Questlog's own output from its last two starts.
26
+ - Questlog's output from the start before the last one is kept, so
27
+ starting A2Qlinux again after a problem no longer erases what shows it.
28
+
29
+ ## [0.7.0] — 2026-11-13
30
+
31
+ ### Changed
32
+ - After updating, run `a2qlinux-setup` once and answer yes to its
33
+ question about Questlog's Open Folder buttons; without that step they
34
+ keep showing Wine's error (see Fixed below).
35
+ - `a2qlinux --diagnose` (and so the problem report) also names the
36
+ distribution, the kernel, the desktop with its version, Wayland or X11,
37
+ and the Proton the game last ran with, so a report shows on which
38
+ system a problem happened.
39
+
40
+ ### Fixed
41
+ - Questlog's **Open Folder** buttons (for example the recordings in the
42
+ Combat Meter) open the folder in the desktop's file manager instead of
43
+ showing "There is no Windows program configured to open this type of
44
+ file". `a2qlinux-setup` explains the fix and asks first; it adds one
45
+ entry to the game's Proton environment, and
46
+ `a2qlinux-setup --no-open-folders` takes it back out.
47
+
6
48
  ## [0.6.0] — 2026-11-12
7
49
 
8
50
  ### Changed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: a2qlinux
3
- Version: 0.6.0
3
+ Version: 0.7.1
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
@@ -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.6.0'
22
- __version_tuple__ = version_tuple = (0, 6, 0)
21
+ __version__ = version = '0.7.1'
22
+ __version_tuple__ = version_tuple = (0, 7, 1)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -74,14 +74,16 @@ def launcher_pid():
74
74
  """PID of the running the launcher (a2qlinux.launcher), from its lock file; None if it cannot be told.
75
75
 
76
76
  Checked against the process's command line, so a stale or reused PID is
77
- never signalled.
77
+ never signalled. The launcher runs as `python -m a2qlinux.launcher` from
78
+ the menu entry and as `python …/a2qlinux-run` when started in a terminal.
78
79
  """
79
80
  try:
80
81
  pid = int(LOCK.read_text().strip())
81
82
  command = Path(f"/proc/{pid}/cmdline").read_bytes().split(b"\0")
82
83
  except (OSError, ValueError):
83
84
  return None
84
- return pid if b"a2qlinux.launcher" in command else None
85
+ ours = b"a2qlinux.launcher" in command or any(os.path.basename(arg) == b"a2qlinux-run" for arg in command)
86
+ return pid if ours else None
85
87
 
86
88
 
87
89
  def ask_running_launcher(game_starting):
@@ -3,17 +3,25 @@
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 graphics cards with their kernel driver and its
8
+ version, what OpenGL renders with, the monitors and the desktop's
9
+ scale, the settings file, Questlog's folder and version.
7
10
  2. The checks a2qlinux-setup makes: programs, capture permission, the tray
8
11
  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.
12
+ 3. Steam: a native installation, the game's prefix, the Proton that last
13
+ ran it, Wine's DPI, Proton/Wine/DXVK/driver variables in Steam's and
14
+ this session's environment, our wpcap.dll in the prefix.
10
15
  4. AION 2's Steam launch option, read from each Steam account's
11
16
  localconfig.vdf, and whether it ever ran (steam_launch.log).
12
17
  5. What runs now: the launcher, Questlog (fed by the bridge or not), the game.
13
18
  6. On KDE Plasma 6, whether the KDE overlays are set up.
19
+ 7. Whether the game's prefix has a command for Questlog's Open Folder
20
+ buttons, read from its system.reg (no Wine is started).
14
21
 
15
22
  With --report it also writes a report file: the diagnosis and the end of
16
- launcher.log, with the home folder, user name, Steam account numbers and
23
+ launcher.log and of questlog.log and questlog.log.1 (Questlog's and Wine's
24
+ output, this run and the one before), with the home folder, user name, Steam account numbers and
17
25
  network addresses replaced (anonymise). It shows the report and, if the
18
26
  user agrees, opens a new GitHub issue in the browser with the report filled
19
27
  in; the user reviews it and submits it with their own account. Nothing is
@@ -23,6 +31,7 @@ sent by this program.
23
31
  import ipaddress
24
32
  import os
25
33
  from pathlib import Path
34
+ import platform
26
35
  import re
27
36
  import shutil
28
37
  import socket
@@ -40,6 +49,9 @@ ISSUES_NEW = "https://github.com/raman78/A2Qlinux/issues/new"
40
49
  # the login page carries the whole URL along); some margin below that.
41
50
  ISSUE_URL_LIMIT = 6000
42
51
  REPORT_LOG_LINES = 400 # lines of launcher.log in the report file: the last few runs
52
+ # questlog.log in the report: whole up to HEAD + TAIL lines, else its start (graphics set-up: DXVK's
53
+ # device, Chromium's GPU process) and its end (what happened last), with the gap marked.
54
+ QUESTLOG_LOG_HEAD, QUESTLOG_LOG_TAIL = 400, 800
43
55
 
44
56
 
45
57
  # ---------------------------------------------------------------- Steam's files
@@ -121,6 +133,265 @@ def judge_launch_option(option, ours):
121
133
 
122
134
  # ---------------------------------------------------------------- checks
123
135
 
136
+ DESKTOP_VERSION = {"KDE": ["plasmashell", "--version"], "GNOME": ["gnome-shell", "--version"]}
137
+ VERSION_WAIT = 5 # s for a desktop's --version
138
+
139
+
140
+ def system_lines(env=os.environ, os_info=None, kernel=None, run=subprocess.run):
141
+ """[(OK, text)]: the distribution, the kernel, the desktop with its version where it says, the session type."""
142
+ from .setup_desktop import os_release
143
+ info = os_release() if os_info is None else os_info
144
+ distro = info.get("PRETTY_NAME") or " ".join(filter(None, (info.get("NAME"), info.get("VERSION_ID"))))
145
+ desktop = env.get("XDG_CURRENT_DESKTOP") or env.get("DESKTOP_SESSION") or "unknown (no XDG_CURRENT_DESKTOP)"
146
+ version = ""
147
+ for name, command in DESKTOP_VERSION.items():
148
+ if name in desktop.upper().split(":") and shutil.which(command[0]):
149
+ try:
150
+ done = run(command, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=VERSION_WAIT)
151
+ version = done.stdout.strip().splitlines()[0] if done.stdout.strip() else ""
152
+ except (OSError, subprocess.TimeoutExpired):
153
+ version = ""
154
+ break
155
+ session = env.get("XDG_SESSION_TYPE") or "unknown session type"
156
+ return [(OK, f"System: {distro or 'unknown distribution (no /etc/os-release)'}, "
157
+ f"kernel {kernel or platform.release()}"),
158
+ (OK, f"Desktop: {desktop}{f' ({version})' if version else ''}, {session}")]
159
+
160
+
161
+ PCI_IDS = ("/usr/share/hwdata/pci.ids", "/usr/share/misc/pci.ids", "/usr/share/pci.ids")
162
+ GLXINFO_WAIT = 5 # s for glxinfo -B
163
+
164
+
165
+ def pci_name(vendor, device, ids_files=PCI_IDS):
166
+ """(vendor name, device name) from the pci.ids database; the hex ids where it has no entry."""
167
+ vendor, device = vendor.lower().removeprefix("0x"), device.lower().removeprefix("0x")
168
+ for path in ids_files:
169
+ try:
170
+ lines = Path(path).read_text(encoding="utf-8", errors="replace").splitlines()
171
+ except OSError:
172
+ continue
173
+ vendor_name, device_name, inside = None, None, False
174
+ for line in lines:
175
+ if not line or line.startswith("#"):
176
+ continue
177
+ if not line.startswith("\t"):
178
+ if inside:
179
+ break
180
+ inside = line[:4].lower() == vendor
181
+ if inside:
182
+ vendor_name = line[4:].strip()
183
+ elif inside and not line.startswith("\t\t") and line[1:5].lower() == device:
184
+ device_name = line[5:].strip()
185
+ break
186
+ if vendor_name:
187
+ return vendor_name, device_name or f"device {device}"
188
+ return f"vendor {vendor}", f"device {device}"
189
+
190
+
191
+ def gpu_lines(sys_root="/", run=subprocess.run, ids_files=PCI_IDS, which=shutil.which):
192
+ """[(level, text)]: each graphics card with its kernel driver (and NVIDIA's version), and OpenGL's renderer.
193
+
194
+ Questlog draws with Chromium on the GPU, so a window that stays black, or
195
+ overlays that do, are first of all a question of card and driver.
196
+ """
197
+ root = Path(sys_root)
198
+ lines = []
199
+ for card in sorted((root / "sys/class/drm").glob("card[0-9]*")):
200
+ if "-" in card.name:
201
+ continue # a connector (card1-DP-1), not a card
202
+ device = card / "device"
203
+ try:
204
+ vendor_id = (device / "vendor").read_text().strip()
205
+ device_id = (device / "device").read_text().strip()
206
+ except OSError:
207
+ continue
208
+ driver = os.path.basename(os.readlink(device / "driver")) if (device / "driver").is_symlink() else "no driver"
209
+ vendor, model = pci_name(vendor_id, device_id, ids_files)
210
+ version = ""
211
+ if driver == "nvidia":
212
+ try:
213
+ found = re.search(r"Kernel Module.*?\s(\d+\.\d+(?:\.\d+)?)\s",
214
+ (root / "proc/driver/nvidia/version").read_text())
215
+ version = f" {found.group(1)}" if found else ""
216
+ except OSError:
217
+ pass
218
+ try:
219
+ primary = (device / "boot_vga").read_text().strip() == "1"
220
+ except OSError:
221
+ primary = False
222
+ lines.append((OK, f"Graphics: {vendor} {model}, driver {driver}{version}" + (" (primary)" if primary else "")))
223
+ if not lines:
224
+ lines.append((NOTE, "Graphics: no card found under /sys/class/drm"))
225
+ if which("glxinfo"):
226
+ try:
227
+ done = run(["glxinfo", "-B"], stdin=subprocess.DEVNULL, capture_output=True, text=True,
228
+ timeout=GLXINFO_WAIT)
229
+ found = dict(re.findall(r"^OpenGL (renderer|version) string: (.+)$", done.stdout, re.MULTILINE))
230
+ except (OSError, subprocess.TimeoutExpired):
231
+ found = {}
232
+ if not found:
233
+ lines.append((NOTE, "OpenGL: unknown (glxinfo -B gave no renderer; no desktop session here?)"))
234
+ else:
235
+ renderer = found.get("renderer", "?")
236
+ software = any(name in renderer.lower() for name in ("llvmpipe", "softpipe", "swrast"))
237
+ lines.append((NOTE if software else OK, f"OpenGL: {renderer}, {found.get('version', '?')}"
238
+ + (" - software rendering: the graphics driver is not in use" if software else "")))
239
+ else:
240
+ lines.append((NOTE, "OpenGL: unknown (glxinfo is not installed)"))
241
+ return lines
242
+
243
+
244
+ XRANDR_WAIT = 5 # s for xrandr / kscreen-doctor
245
+ # Environment variables that change how Proton, Wine, DXVK or the graphics driver behave.
246
+ ENV_PREFIXES = ("PROTON_", "DXVK_", "VKD3D_", "WINE", "__GL_", "__GLX_", "MESA_", "RADV_", "AMD_VULKAN",
247
+ "VK_ICD_FILENAMES", "VK_DRIVER_FILES", "VK_LOADER", "DRI_PRIME", "ENABLE_VKBASALT",
248
+ "MANGOHUD", "LD_PRELOAD", "SDL_VIDEODRIVER", "STEAM_COMPAT_")
249
+
250
+
251
+ def display_lines(env=os.environ, run=subprocess.run, which=shutil.which, home=None):
252
+ """[(level, text)]: the monitors as X11 programs (Wine, so Questlog) see them, and the desktop's scale.
253
+
254
+ Wine draws through X11 (XWayland in a Wayland session), so `xrandr` shows
255
+ the screens and positions Questlog places its overlays on. The scale is
256
+ the desktop's own: KDE's from kscreen-doctor, GNOME's from monitors.xml.
257
+ """
258
+ lines = []
259
+ if which("xrandr") and env.get("DISPLAY"):
260
+ try:
261
+ done = run(["xrandr", "--listmonitors"], stdin=subprocess.DEVNULL, capture_output=True, text=True,
262
+ timeout=XRANDR_WAIT)
263
+ monitors = re.findall(r"^\s*\d+: [+*]*(\S+) (\d+)/\d+x(\d+)/\d+([+-]\d+[+-]\d+)", done.stdout,
264
+ re.MULTILINE)
265
+ except (OSError, subprocess.TimeoutExpired):
266
+ monitors = []
267
+ lines.append((OK, "Monitors (as Wine sees them): "
268
+ + ", ".join(f"{name} {w}x{h} at {pos}" for name, w, h, pos in monitors)) if monitors else
269
+ (NOTE, "Monitors: unknown (xrandr --listmonitors gave none)"))
270
+ elif not env.get("DISPLAY"):
271
+ lines.append((NOTE, "Monitors: unknown (no X11 display here; run this in the desktop session)"))
272
+ else:
273
+ lines.append((NOTE, "Monitors: unknown (xrandr is not installed)"))
274
+ desktop = env.get("XDG_CURRENT_DESKTOP", "").upper().split(":")
275
+ scales = []
276
+ if "KDE" in desktop and which("kscreen-doctor"):
277
+ try:
278
+ done = run(["kscreen-doctor", "-j"], stdin=subprocess.DEVNULL, capture_output=True, text=True,
279
+ timeout=XRANDR_WAIT)
280
+ import json
281
+ scales = [f"{o['name']} {o.get('scale', 1):g}" for o in json.loads(done.stdout).get("outputs", [])
282
+ if o.get("enabled")]
283
+ except (OSError, subprocess.TimeoutExpired, ValueError, KeyError, TypeError):
284
+ scales = []
285
+ elif "GNOME" in desktop:
286
+ xml = Path(home or Path.home()) / ".config" / "monitors.xml"
287
+ try:
288
+ found = re.findall(r"<scale>([\d.]+)</scale>", xml.read_text(errors="replace"))
289
+ scales = [f"{float(value):g}" for value in found] or ["1"]
290
+ except OSError:
291
+ scales = ["1 (no monitors.xml: never changed)"]
292
+ if scales:
293
+ lines.append((OK, "Desktop scale: " + ", ".join(scales)))
294
+ elif "KDE" in desktop:
295
+ lines.append((NOTE, "Desktop scale: unknown (kscreen-doctor is missing or gave no outputs)"))
296
+ elif "GNOME" not in desktop:
297
+ lines.append((NOTE, "Desktop scale: unknown on this desktop (read on KDE and GNOME only)"))
298
+ return lines
299
+
300
+
301
+ def wine_dpi_line(prefix):
302
+ """(OK, text): the DPI values set in the prefix's registry, each with its key (96 is 100 %)."""
303
+ found = []
304
+ for name, key in (("user.reg", r"[Control Panel\\Desktop]"), ("user.reg", r"[Software\\Wine\\Fonts]"),
305
+ ("system.reg", r"[System\\CurrentControlSet\\Hardware Profiles\\Current\\Software\\Fonts]"),
306
+ ("system.reg", r"[System\\ControlSet001\\Hardware Profiles\\Current\\Software\\Fonts]")):
307
+ try:
308
+ text = (Path(prefix) / name).read_text(encoding="utf-8", errors="replace")
309
+ except OSError:
310
+ continue
311
+ start = text.find("\n" + key + " ")
312
+ if start < 0:
313
+ continue
314
+ end = text.find("\n[", start + 1)
315
+ value = re.search(r'^"LogPixels"=dword:([0-9a-fA-F]+)$', text[start:end if end > 0 else None], re.MULTILINE)
316
+ if value:
317
+ shown = key.strip("[]").replace("\\\\", "\\")
318
+ found.append(f"{int(value.group(1), 16)} in {shown}")
319
+ return OK, "Wine DPI: " + ("; ".join(found) if found else "not set (Wine's default, 96)")
320
+
321
+
322
+ def env_settings(environ):
323
+ """The entries of `environ` (a dict) that change how Proton, Wine, DXVK or the driver behave, sorted."""
324
+ return sorted(f"{k}={v}" for k, v in environ.items() if k.startswith(ENV_PREFIXES))
325
+
326
+
327
+ STEAM_PROGRAMS = (b"/steam.sh", b"/steamrt64/steam", b"/ubuntu12_64/steam", b"/ubuntu12_32/steam")
328
+
329
+
330
+ def steam_environment(proc="/proc"):
331
+ """The Steam client's environment as a dict, None when Steam is not running.
332
+
333
+ steam.sh's is preferred (run as `bash …/steam.sh`): it is what the
334
+ session handed to Steam, before Steam's own runtime adds to it.
335
+ """
336
+ found = {}
337
+ with os.scandir(proc) as entries:
338
+ for entry in entries:
339
+ if not entry.name.isdigit():
340
+ continue
341
+ try:
342
+ argv = Path(entry.path, "cmdline").read_bytes().split(b"\0")[:2]
343
+ program = next((STEAM_PROGRAMS.index(p) for p in STEAM_PROGRAMS for a in argv if a.endswith(p)), None)
344
+ if program is None or program in found:
345
+ continue
346
+ raw = Path(entry.path, "environ").read_bytes()
347
+ except OSError:
348
+ continue
349
+ found[program] = dict(item.split("=", 1) for item in raw.decode("utf-8", "replace").split("\0")
350
+ if "=" in item)
351
+ return found[min(found)] if found else None
352
+
353
+
354
+ def environment_lines(env=os.environ, steam_environ=False):
355
+ """[(level, text)]: such variables in Steam's environment (what the game starts with) and in this session's."""
356
+ def listed(environ):
357
+ settings = env_settings(environ)
358
+ return ", ".join(settings) if settings else "no Proton, Wine, DXVK or driver variables"
359
+ steam = steam_environment() if steam_environ is False else steam_environ
360
+ return [(OK, "Steam's environment: " + (listed(steam) if steam is not None else "unknown (Steam is not running)")),
361
+ (OK, "This session's environment (Questlog's): " + listed(env))]
362
+
363
+
364
+ def proton_line(prefix, host_root="/"):
365
+ """(level, text): the Proton that last ran the prefix.
366
+
367
+ Proton rewrites config_info beside the prefix on a start whenever it
368
+ differs. Its first line is the prefix's format version
369
+ (CURRENT_PREFIX_VERSION, e.g. "11.0-100"), which many builds share; the
370
+ lines below are paths inside the Proton tool's folder, as the Steam
371
+ runtime container sees them (/run/host/... is the host's /...). The
372
+ build's own name is in that folder's `version` file ("<time> <name>").
373
+ """
374
+ try:
375
+ lines = (Path(prefix).parent / "config_info").read_text(errors="replace").splitlines()
376
+ except OSError:
377
+ return NOTE, "Proton: unknown (no config_info next to the prefix; the game not started yet?)"
378
+ prefix_version = lines[0].strip() if lines else ""
379
+ folder = next((line.split("/files/", 1)[0] for line in lines[1:] if "/files/" in line), "")
380
+ if folder.startswith("/run/host/"):
381
+ folder = folder[len("/run/host"):]
382
+ build = ""
383
+ if folder:
384
+ try:
385
+ build = (Path(host_root) / folder.lstrip("/") / "version").read_text(errors="replace").split()[-1]
386
+ except (OSError, IndexError):
387
+ build = ""
388
+ if not (build or prefix_version):
389
+ return NOTE, "Proton: unknown (config_info is empty)"
390
+ tool = Path(folder).name if folder else ""
391
+ shown = build or f"build unknown, prefix version {prefix_version}"
392
+ return OK, f"Proton (last run): {shown}" + (f" (folder {tool})" if tool else "")
393
+
394
+
124
395
  def check_setup(results):
125
396
  from . import setup_desktop as setup
126
397
  info = setup.os_release()
@@ -153,6 +424,9 @@ def check_steam(results, appid, qdir):
153
424
  try:
154
425
  prefix = launcher.game_prefix(appid, roots)
155
426
  results.append((OK, f"Game prefix: {prefix}"))
427
+ results.append(proton_line(prefix))
428
+ results.append(wine_dpi_line(prefix))
429
+ results += environment_lines()
156
430
  dll = prefix / "drive_c" / "windows" / "system32" / "Npcap" / "wpcap.dll"
157
431
  try:
158
432
  ours = launcher.BRIDGE_SIGNATURE in dll.read_bytes()
@@ -204,7 +478,8 @@ def check_running(results, appid):
204
478
  "icon and start 'A2Qlinux' from the menu"))
205
479
  elif not running:
206
480
  results.append((PROBLEM, "Now: Questlog runs with the bridge, but A2Qlinux has ended (status "
207
- "window closed?): it gets no game traffic. Quit it and start it again"))
481
+ "window closed?): it gets no game traffic. Start 'A2Qlinux' from the menu: "
482
+ "it closes this Questlog and starts it again"))
208
483
  else:
209
484
  results.append((OK, "Now: Questlog runs under A2Qlinux"))
210
485
  else:
@@ -223,18 +498,44 @@ def check_kde(results):
223
498
  "(a2qlinux-setup --kde-overlays)"))
224
499
 
225
500
 
501
+ def check_open_folders(results, appid, prefix=None):
502
+ from . import launcher, open_folders
503
+ try:
504
+ prefix = prefix or launcher.game_prefix(appid)
505
+ except RuntimeError:
506
+ return # reported by check_steam
507
+ state, value = open_folders.registry_state(prefix / "system.reg")
508
+ if state == "ours":
509
+ results.append((OK, "Open Folder: set up; Questlog's folders open in the file manager"))
510
+ elif state == "other":
511
+ results.append((NOTE, f"Open Folder: the prefix has another command for opening folders "
512
+ f"({value or 'a key without a command'}); A2Qlinux leaves it as it is"))
513
+ else:
514
+ results.append((NOTE, "Open Folder: not set up; Questlog's Open Folder buttons show Wine's \"no Windows "
515
+ "program configured\" (a2qlinux-setup --open-folders; a change made in the last "
516
+ "30 s may not be saved to the prefix yet)"))
517
+
518
+
226
519
  def diagnose(appid=3393110):
227
520
  """[(level, text)], in the order of the module docstring."""
228
521
  settings, problems = config.load()
229
522
  qdir = settings.questlog_dir.expanduser()
230
- results = [(OK, f"A2Qlinux {shown_version()}"), (OK, f"Settings: {config.CONFIG_PATH}")]
523
+ results = [(OK, f"A2Qlinux {shown_version()}")]
524
+ try:
525
+ results += system_lines()
526
+ results += gpu_lines()
527
+ results += display_lines()
528
+ except Exception as error: # as below: reported, never hiding the rest
529
+ results.append((PROBLEM, f"This check failed: {error!r} (please report it)"))
530
+ results.append((OK, f"Settings: {config.CONFIG_PATH}"))
231
531
  results += [(PROBLEM, f"Settings: {p}") for p in problems]
232
532
  if (qdir / "Questlog.exe").is_file():
233
533
  from .update import installed_version
234
534
  results.append((OK, f"Questlog: {installed_version(qdir) or 'version unreadable'} in {qdir}"))
235
535
  else:
236
536
  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):
537
+ for check in (check_setup, lambda r: check_steam(r, appid, qdir), lambda r: check_running(r, appid), check_kde,
538
+ lambda r: check_open_folders(r, appid)):
238
539
  try:
239
540
  check(results)
240
541
  except Exception as error: # one broken check must not hide the others; it is reported
@@ -252,7 +553,7 @@ def format_results(results):
252
553
  class Anonymiser:
253
554
  """Replaces what identifies the user or their network, the same value always the same way.
254
555
 
255
- Home folder -> ~, the user name as a path component -> <user>, Steam
556
+ Home folder -> ~, the user name as a path component (also in Wine's Windows paths) -> <user>, Steam
256
557
  account folders -> userdata/<steam-id-N>, the host name -> <host>,
257
558
  IPv4 and IPv6 addresses -> <private-N> / <public-N> / <ipv6-N> (loopback
258
559
  and 0.0.0.0 stay, they say nothing about anyone). A consistent
@@ -302,7 +603,8 @@ class Anonymiser:
302
603
  for home in {self.home, os.path.realpath(self.home)}:
303
604
  text = text.replace(home, "~")
304
605
  if self.user:
305
- text = re.sub(rf"(?<=/){re.escape(self.user)}(?=/|\b)", "<user>", text)
606
+ # Linux paths, and Wine's Windows ones (Z:\home\<user>\..., also with doubled backslashes)
607
+ text = re.sub(rf"(?<=[/\\]){re.escape(self.user)}(?=[/\\]|\b)", "<user>", text)
306
608
  text = self.STEAM_ID.sub(lambda m: m.group(1) + self._name("steam-id", m.group(2)), text)
307
609
  if self.host and len(self.host) >= 3:
308
610
  text = re.sub(rf"\b{re.escape(self.host)}\b", "<host>", text)
@@ -319,6 +621,17 @@ def log_tail(path, lines):
319
621
  return []
320
622
 
321
623
 
624
+ def questlog_log_excerpt(path, head=QUESTLOG_LOG_HEAD, tail=QUESTLOG_LOG_TAIL):
625
+ """questlog.log's lines for the report: all of them, or its start and end with the gap marked."""
626
+ try:
627
+ lines = path.read_text(errors="replace").splitlines()
628
+ except OSError:
629
+ return []
630
+ if len(lines) <= head + tail:
631
+ return lines
632
+ return lines[:head] + [f"(... {len(lines) - head - tail} lines left out ...)"] + lines[-tail:]
633
+
634
+
322
635
  def build_report(results, qdir, anonymise):
323
636
  logs = qdir / "proton-stream"
324
637
  launcher_lines = log_tail(logs / "launcher.log", REPORT_LOG_LINES)
@@ -327,6 +640,10 @@ def build_report(results, qdir, anonymise):
327
640
  parts += launcher_lines or ["(no launcher.log yet)"]
328
641
  parts += ["", "## steam_launch.log (last 10 lines)", ""]
329
642
  parts += log_tail(logs / "steam_launch.log", 10) or ["(none)"]
643
+ parts += ["", "## questlog.log (Questlog's and Wine's output since A2Qlinux last started it)", ""]
644
+ parts += questlog_log_excerpt(logs / "questlog.log") or ["(none)"]
645
+ parts += ["", "## questlog.log.1 (the run before that)", ""]
646
+ parts += questlog_log_excerpt(logs / "questlog.log.1", head=200, tail=400) or ["(none)"]
330
647
  return anonymise("\n".join(parts) + "\n")
331
648
 
332
649
 
@@ -575,6 +575,7 @@ def session_lock(directory):
575
575
  # ----------------------------------------------------------- tray and quit
576
576
 
577
577
  CTL = BIN / "questlog_ctl.exe"
578
+ ORPHAN_EXIT_FILE_WAIT = 5 # s for an ended orphan's launch to write questlog.exit (end_orphaned_questlog)
578
579
  SAVE_WAIT = 10.5 # s after the last game data before Questlog may be ended: it saves pending data within 10 s
579
580
 
580
581
 
@@ -990,6 +991,63 @@ def end_game_steam_helper(why, pids=None):
990
991
  return len(orphans) - len(left)
991
992
 
992
993
 
994
+ def start_questlog_log(path):
995
+ """Begin this launcher run's questlog.log; the previous run's becomes questlog.log.1.
996
+
997
+ One log per launcher run (relaunches within it append). The previous one
998
+ is kept because a player who restarts A2Qlinux after a problem would
999
+ otherwise empty the log that shows it, before making a report.
1000
+ """
1001
+ path = Path(path)
1002
+ try:
1003
+ if path.stat().st_size:
1004
+ os.replace(path, path.with_name(path.name + ".1"))
1005
+ except FileNotFoundError:
1006
+ pass
1007
+ path.write_bytes(b"")
1008
+
1009
+
1010
+ def running_questlog_state(pids):
1011
+ """None (no Questlog), "orphaned" (started with the bridge) or "outside" (started without A2Qlinux).
1012
+
1013
+ Asked by a launcher that holds the session lock (I1), so no other launcher
1014
+ runs: a Questlog carrying QUESTLOG_PROTON_BRIDGE was started by a launcher
1015
+ that has ended since (its status window closed), and gets no traffic.
1016
+ """
1017
+ if not pids:
1018
+ return None
1019
+ fed = any("QUESTLOG_PROTON_BRIDGE=" in _read(f"/proc/{pid}/environ") for pid in pids)
1020
+ return "orphaned" if fed else "outside"
1021
+
1022
+
1023
+ def end_orphaned_questlog(protontricks, log_path, wait=SAVE_WAIT):
1024
+ """End a Questlog whose launcher has gone, so that this launcher can start it with its own bridge.
1025
+
1026
+ Its tray icon was hidden by that launcher and ours went with it, so the
1027
+ player cannot quit it. It is ended like a quit (end-session: Questlog's
1028
+ window only, the game is not touched), after `wait` seconds in which
1029
+ Questlog saves what it received before its bridge went away. A Questlog
1030
+ that does not answer (its window hung) is stopped by wait_for_questlog_exit.
1031
+
1032
+ Its launch (launch_questlog) writes questlog.exit once Questlog has gone;
1033
+ that is waited for too, since a file written after this launcher's own
1034
+ launch would read as the new Questlog's end.
1035
+ """
1036
+ log("Questlog is still running from an A2Qlinux that has ended (its status window was closed?), so it "
1037
+ f"gets no game traffic. Closing it in {wait:.0f} s, once it has saved, and starting it again.")
1038
+ time.sleep(wait)
1039
+ if run_ctl(protontricks, "end-session", log_path) != 0:
1040
+ log(f"Questlog did not take the session end; its processes are stopped within {QUESTLOG_QUIT_WAIT} s.")
1041
+ wait_for_questlog_exit(f"it had {wait:.0f} s to save")
1042
+ exit_file = Path(log_path).with_name("questlog.exit")
1043
+ deadline = time.monotonic() + ORPHAN_EXIT_FILE_WAIT
1044
+ while not exit_file.exists() and time.monotonic() < deadline:
1045
+ time.sleep(0.2)
1046
+ if game_processes(APPID, ["questlog.exe"])["questlog.exe"]:
1047
+ raise RuntimeError("Questlog keeps running from an A2Qlinux that has ended and could not be closed. "
1048
+ "End its Questlog.exe processes (System Monitor), then start A2Qlinux again.")
1049
+
1050
+
993
1051
  def move_to_fresh_session(prefix, protontricks, log_path):
994
1052
  """End Questlog and wait until the game's Wine session is gone. Returns True if it went.
995
1053
 
@@ -1302,12 +1360,10 @@ def main():
1302
1360
  # Only the launcher holding the lock writes the file; earlier lines are kept until now.
1303
1361
  LOG_FILE.open(state_dir / "launcher.log")
1304
1362
  dumpcap = system_dumpcap()
1305
- running = game_processes(APPID, ["questlog.exe"])["questlog.exe"]
1306
- if running:
1307
- fed = any("QUESTLOG_PROTON_BRIDGE=" in _read(f"/proc/{pid}/environ") for pid in running)
1308
- if fed:
1309
- raise RuntimeError("Questlog is already running and fed by another A2Qlinux "
1310
- "(another terminal window). Nothing to do here.")
1363
+ running = running_questlog_state(game_processes(APPID, ["questlog.exe"])["questlog.exe"])
1364
+ if running == "orphaned":
1365
+ end_orphaned_questlog(protontricks, state_dir / "questlog.log")
1366
+ elif running == "outside":
1311
1367
  raise RuntimeError("Questlog is already running in the game prefix without the capture bridge. "
1312
1368
  "Quit it (tray icon > Quit) and run this again.")
1313
1369
  server = BridgeServer(log)
@@ -1325,7 +1381,7 @@ def main():
1325
1381
  log("AION 2 is not running; starting Questlog now (saved fights, database, map). "
1326
1382
  "Start the game any time - its traffic then flows to Questlog.")
1327
1383
  log_path = state_dir / "questlog.log"
1328
- log_path.write_bytes(b"") # one log per launcher run; relaunches append
1384
+ start_questlog_log(log_path)
1329
1385
  tray = Tray(requests)
1330
1386
  quit_control = QuitControl()
1331
1387