Repository navigation
feat(wayland): auto-detect Wayland session and start aw-watcher-window-wayland - #142
Conversation
On Wayland, aw-watcher-window and aw-watcher-afk do not work (they rely on X11/xcb). aw-watcher-window-wayland handles both roles via Wayland protocols (wlr-foreign-toplevel-management-unstable-v1 + ext-idle-notify-v1). Add _is_wayland() which checks WAYLAND_DISPLAY and XDG_SESSION_TYPE, and _apply_wayland_substitutions() which swaps the two X11 modules for aw-watcher-window-wayland when the Wayland watcher is installed. The substitution is transparent: the default autostart_modules config is unchanged, the swap happens at runtime in Manager.autostart(). When aw-watcher-window-wayland is not installed, the original list is returned with a warning — no breakage, just no window/AFK tracking. Closes ActivityWatch/activitywatch#92 (Wayland support in aw-qt) Git-Session-Id: 2a88ce4d-a37f-436a-bbf8-48c828da3b4d
[Medium impact] Auto-detects Wayland and swaps window tracking modules. Preserve the user's choice to disable startup before merging. FindingsSummaryAdds Wayland detection and replaces the X11 watchers with an installed
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Configured or command-line module list] --> B{Wayland session?}
B -- No --> F[Validate and remove duplicates]
B -- Yes --> C{Wayland watcher installed?}
C -- No --> F
C -- Yes --> D[Replace selected X11 watchers]
D --> E[Also append watcher when none selected]
E --> F
F --> G[Start selected server first]
G --> H[Start remaining modules]
Reviews (1) · Last reviewed commit: "feat(wayland): auto-detect Wayland and s..." · Reviewed by Greptile |
Greptile P1: the substitution helper appended aw-watcher-window-wayland even when autostart_modules was empty (--autostart-modules none) or server-only, overriding an explicit choice to disable tracking. Only replace modules the user actually selected; leave empty and server-only lists untouched. Add regression tests for the empty and server-only cases. Also drop the sys.modules PyQt6 stubs from the tests (PyQt6 imports fine without a display, and the stubs leaked MagicMock modules into other tests) and remove the unused imports CodeQL flagged. Git-Session-Id: 98c07e2a-30f9-5f17-a998-4fb560a3876e
🤖 AI code reviewSafe to merge — 1 P1 disposed (accepted-tradeoff)Updated after inline dispositions on finding threads — this is the current state; the verdict below is frozen at review time and is kept as the historical record of that pass. Finding disposition
Adds Wayland session detection ( Not safe to merge — 1 P1 openConfidence 3/5 1 finding · ❌ 1 P1❌ P1 high — When only one of the two X11 watchers is in the autostart list, the substitution still inserts aw-watcher-window-wayland, which reports to both the aw-watcher-window and aw-watcher-afk buckets. For example autostart_modules=['aw-server','aw-watcher-window'] on Wayland with the wayland watcher installed becomes ['aw-server','aw-watcher-window-wayland'], silently enabling AFK tracking the user deliberately omitted. This contradicts the docstring's claim that only modules the user actually selected are replaced; the pair is treated as atomic. Observable consequence: users who disabled AFK tracking for privacy will have AFK data collected after switching to Wayland. How this was verified: Traced the loop for Consensus: 3/3 passes agreed Files changed (2) — the diff as I read it
Reviewed Maintainer commands
|
Merge recommendationFixed this cycle (head
Remaining (non-blocking):
Verified against: head CI: all green (Test ubuntu-22.04 / macos-14 / windows-latest, Analyze, CodeQL). Domain risk for maintainer judgment: the partial-selection AFK-bucket semantics above — if you consider silently enabling AFK collection for a user who deliberately omitted Convergence: detector verdict |
Summary
On Wayland,
aw-watcher-windowandaw-watcher-afkdo not work — they rely on X11/xcb APIs.aw-watcher-window-waylandalready handles both roles (it writes to both theaw-watcher-windowandaw-watcher-afkbuckets), but users had to manually disable the X11 watchers and start the Wayland one themselves.This PR makes aw-qt handle the swap transparently:
_is_wayland(): detects Wayland by checkingWAYLAND_DISPLAYorXDG_SESSION_TYPE=wayland_apply_wayland_substitutions(): when on Wayland andaw-watcher-window-waylandis installed, dropsaw-watcher-windowandaw-watcher-afkfrom the autostart list and insertsaw-watcher-window-waylandin their placeautostart_modulesconfig is unchanged — the swap happens at runtime inManager.autostart()aw-watcher-window-waylandis not installed, the original list is returned with a warning (graceful degradation)Addresses the concern raised by Erik in ActivityWatch/activitywatch#92: system package managers on Wayland-first distros may only list the Tauri distribution if aw-qt is broken on Wayland. With this fix, aw-qt works on Wayland when
aw-watcher-window-waylandis installed.Test plan
_is_wayland()and_apply_wayland_substitutions()— all passmake test)aw-watcher-window-waylandstarts instead of the X11 watchersCo-Authored-By: Bob timetobuildBob@gmail.com