How activitywatch/aw-qt works
Project type and purpose
• Its primary job is to start, stop, and monitor the aw-server and its watchers, and provide a system tray UI for user control and status feedback.
File structure
• aw_qt/
– __main__.py, main.py: application entry points
– config.py: configuration loader/parser
– manager.py: logic to spawn, monitor, and control aw-server and watchers
• scripts/config-autostart.sh: system/user autostart helper
• Makefile, aw-qt.spec, pyproject.toml: build, packaging, dependencies
• .github/workflows: CI for build and code analysis
• tests/integration_tests.py: end‐to‐end testing
README for additional insights
• Directs to Makefile for build instructions—so packaging and distribution are core concerns.
Main components and their interactions
a. User Interface (UI)
– Settings Dialog (if any, via config.py)
b. Service Manager
– Process control: start/stop aw-server and watcher subprocesses (manager.py)
– Health checks and restart logic
c. Configuration
– Reads/writes config file (config.py)
– Autostart script integration (scripts/config-autostart.sh)
d. External Services
– aw-server (HTTP/REST API for data collection)
– Watchers (processes sending events to aw-server)
e. Packaging & Deployment
– .desktop file for desktop environments (resources/)
– spec file for RPM (aw-qt.spec)
– Makefile/pyproject.toml for build, versioning, and dependency management
Relationships and data flows
• UI → Service Manager: user clicks in tray menu to start/stop services
• Service Manager → aw-server & watchers: launches subprocesses and monitors stdout/exit codes
• aw-server ↔ watchers: watchers send activity events to the server’s REST endpoint
• Service Manager ← Configuration: reads config on startup, writes updates on user changes
• Autostart Script ↔ OS: installs or removes the aw-qt.desktop entry for login launch
Architectural patterns and design principles
• Modular separation: UI logic (trayicon.py) is decoupled from process-control logic (manager.py)
• Single responsibility: config, UI, and management each in its own module
• Externalization of assets and packaging: resources/ and scripts/ keep deployment concerns separate