#!/usr/bin/env python3
# SPDX-License-Identifier: LicenseRef-CMSD-1.0
# Copyright (c) 2026 CyberMind — Gérald Kerma <devel@cybermind.fr>
# Source-Disclosed License — All rights reserved except as expressly granted.
# See LICENCE-CMSD-1.0.md for terms.

"""
SecuBox-Deb :: streamlit-shotter — captures ONE Streamlit app's thumbnail

Launched as a DETACHED background process by `api/main.py` (secubox-
streamlit), never by a timer (#958) — the two triggers are a wake that just
succeeded and an explicit "recapturer" click. All the logic (target
resolution via `streamlitctl app shot-target`, staleness check, exclusion
lock, the actual capture) lives in `api/shots.py` — importable and tested
independently of this entry point. This script only puts `api/` on
`sys.path` and calls `shots.main()`.

Runs unprivileged as `secubox` — chromium doesn't need root, only the
target-resolution step (`streamlitctl`, invoked from inside shots.py) goes
through `sudo -n`, exactly like every other streamlitctl call made by the
API.

Path/binary overrides (see `shots.main`):
  STREAMLIT_LIB                     default /usr/lib/secubox/streamlit/api
  SECUBOX_STREAMLIT_SHOTS_CACHE     default /var/cache/secubox/streamlit/shots
  SECUBOX_STREAMLIT_CTL             default /usr/sbin/streamlitctl
"""
import os
import sys

LIB = os.environ.get("STREAMLIT_LIB", "/usr/lib/secubox/streamlit/api")
if LIB not in sys.path:
    sys.path.insert(0, LIB)

import shots  # noqa: E402  (sys.path must be set up first)

if __name__ == "__main__":
    raise SystemExit(shots.main())
