Files
upstream-activitywatch/scripts/patch_research_edition_awqt.py
upstream-mirror c5c5af8cde
Some checks failed
Research feed publisher tests / test (push) Failing after 3s
Release / Pre-flight checks (push) Failing after 0s
Release / Research Edition — patch and packaging smoke tests (push) Has been skipped
Release / Build Qt artifacts (false, 22, ubuntu-22.04, 3.9, ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')) }}, false, false) (push) Has been skipped
Release / Build Qt artifacts (false, 22, ubuntu-22.04, 3.9, false, false, false) (push) Has been skipped
Release / Build Qt artifacts (manylinux_2_28 — glibc 2.28 ABI floor) (22, 3.9) (push) Has been skipped
Release / Generate release notes (push) Has been skipped
Release / Create dev release tag (push) Has been skipped
CodeQL / Analyze (javascript) (push) Failing after 1s
CodeQL / Analyze (python) (push) Failing after 1s
Release / Build Qt artifacts (false, 22, windows-latest, 3.9, false, false, false) (push) Has been cancelled
Release / Build Tauri artifacts (false, 22, macos-15-intel, 3.9, false, false, false) (push) Has been cancelled
Release / Build Tauri artifacts (false, 22, macos-latest, 3.9, false, false, false) (push) Has been cancelled
Release / Build Tauri artifacts (false, 22, ubuntu-24.04, 3.9, ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')) }}, false, false) (push) Has been cancelled
Release / Build Tauri artifacts (false, 22, ubuntu-24.04, 3.9, false, false, false) (push) Has been cancelled
Release / Build Tauri artifacts (false, 22, ubuntu-24.04-arm, 3.9, false, false, false) (push) Has been cancelled
Release / Build Tauri artifacts (false, 22, windows-latest, 3.9, false, false, false) (push) Has been cancelled
Release / Build Qt artifacts (false, 22, macos-15-intel, 3.9, false, false, false) (push) Has been cancelled
Release / Build Qt artifacts (false, 22, macos-latest, 3.9, false, false, false) (push) Has been cancelled
Release / Publish draft release (push) Has been cancelled
snapshot of https://github.com/ActivityWatch/activitywatch.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:29:06 +05:00

53 lines
1.7 KiB
Python
Executable File

#!/usr/bin/env python3
"""Patch aw-qt's default config for Research Edition builds.
Flips `autostart_on_first_run` from false to true in aw_qt/config.py's
default_config, so participant machines register start-at-login on first
launch (aw-qt#131) without any setup steps. The user can still disable it
from the tray afterwards; aw-qt never re-enables once its marker is written.
Run as part of the CI build for research edition:
python3 scripts/patch_research_edition_awqt.py <path/to/aw_qt/config.py>
Fails closed if the key is absent, which means the aw-qt submodule pin
predates aw-qt#131 — bump the pin rather than shipping a research build
that silently loses reboot-survival.
"""
import pathlib
import sys
OLD = "autostart_on_first_run = false"
NEW = "autostart_on_first_run = true"
def main() -> int:
if len(sys.argv) != 2:
print(f"usage: {sys.argv[0]} <path/to/aw_qt/config.py>", file=sys.stderr)
return 2
path = pathlib.Path(sys.argv[1])
try:
text = path.read_text()
except FileNotFoundError:
print(f"ERROR: {path} not found - is the aw-qt submodule checked out?", file=sys.stderr)
return 1
# Only patch the first occurrence: the [aw-qt] section default. The
# [aw-qt-testing] section keeps autostart off.
if OLD not in text:
print(
f"ERROR: {OLD!r} not found in {path} - aw-qt submodule pin "
"predates aw-qt#131, refusing to build research edition without "
"first-run autostart",
file=sys.stderr,
)
return 1
path.write_text(text.replace(OLD, NEW, 1))
print(f"Patched {path}: {OLD} -> {NEW} (first occurrence)")
return 0
if __name__ == "__main__":
sys.exit(main())