photon_platform.clerk.service

Declarative systemd --user and XDG .desktop service manager for PHOTON web apps.

Functions

default_systemd_user_dir() → pathlib.Path

Return ~/.config/systemd/user (honoring XDG_CONFIG_HOME).

default_applications_dir() → pathlib.Path

Return ~/.local/share/applications (honoring XDG_DATA_HOME).

render_systemd_unit(spec) → str

Render an unprivileged systemd --user unit file for spec.

render_desktop_entry(spec, *[, launcher_bin]) → str

Render an XDG .desktop file for Pop!_OS Super launcher and Alt-Tab identity.

service_status(service_id, *[, systemd_dir]) → dict[str, Any]

Inspect installation and live systemd --user status for service_id.

install_service(spec, *[, systemd_dir, ...]) → dict[str, Any]

Write .service and .desktop files for spec and optionally enable/start it.

uninstall_service(service_id, *[, systemd_dir, ...]) → dict[str, Any]

Disable, stop, and remove the .service and .desktop files for service_id.

control_service(service_id, verb) → dict[str, Any]

Run systemctl --user <verb> <service_id>.service.

service_logs(service_id, *[, lines]) → dict[str, Any]

Fetch recent journalctl --user logs for service_id.

probe_service_health(spec, *[, systemd_dir]) → dict[str, Any]

Combine systemd status, live TCP port reachability, and command interpreter check.

install_all_services(*[, config, systemd_dir, ...]) → list[dict[str, Any]]

Install systemd units and .desktop launchers for every discovered PHOTON service.

launch_service_window(spec, *[, new_window, detach, ...]) → dict[str, Any]

Launch or raise spec inside a standalone GTK3/WebKit2GTK photon-app window.

render_services_toml(specs) → str

Serialize service specifications to a clean documented services.toml file.

service_cmd() → None

Manage persistent systemd --user background services and .desktop launchers.

Module Contents

photon_platform.clerk.service.default_systemd_user_dir() → pathlib.Path

Return ~/.config/systemd/user (honoring XDG_CONFIG_HOME).

photon_platform.clerk.service.default_applications_dir() → pathlib.Path

Return ~/.local/share/applications (honoring XDG_DATA_HOME).

photon_platform.clerk.service.render_systemd_unit(spec: photon_platform.clerk.config.ServiceSpec) → str

Render an unprivileged systemd --user unit file for spec.

Parameters:

spec – Declarative ServiceSpec.

Returns:

Formatted INI unit file text.

photon_platform.clerk.service.render_desktop_entry(spec: photon_platform.clerk.config.ServiceSpec, *, launcher_bin: str | None = None) → str

Render an XDG .desktop file for Pop!_OS Super launcher and Alt-Tab identity.

Parameters:
  • spec – Declarative ServiceSpec.

  • launcher_bin – Explicit path to photon-app (defaults to ~/.local/bin/photon-app).

Returns:

Formatted .desktop file text.

photon_platform.clerk.service.service_status(service_id: str, *, systemd_dir: pathlib.Path | None = None) → dict[str, Any]

Inspect installation and live systemd --user status for service_id.

photon_platform.clerk.service.install_service(spec: photon_platform.clerk.config.ServiceSpec, *, systemd_dir: pathlib.Path | None = None, applications_dir: pathlib.Path | None = None, enable: bool = True, start: bool = True, dry_run: bool = False) → dict[str, Any]

Write .service and .desktop files for spec and optionally enable/start it.

photon_platform.clerk.service.uninstall_service(service_id: str, *, systemd_dir: pathlib.Path | None = None, applications_dir: pathlib.Path | None = None, dry_run: bool = False) → dict[str, Any]

Disable, stop, and remove the .service and .desktop files for service_id.

photon_platform.clerk.service.control_service(service_id: str, verb: str) → dict[str, Any]

Run systemctl --user <verb> <service_id>.service.

photon_platform.clerk.service.service_logs(service_id: str, *, lines: int = 80) → dict[str, Any]

Fetch recent journalctl --user logs for service_id.

photon_platform.clerk.service.probe_service_health(spec: photon_platform.clerk.config.ServiceSpec, *, systemd_dir: pathlib.Path | None = None) → dict[str, Any]

Combine systemd status, live TCP port reachability, and command interpreter check.

photon_platform.clerk.service.install_all_services(*, config: photon_platform.clerk.config.ClerkConfig | None = None, systemd_dir: pathlib.Path | None = None, applications_dir: pathlib.Path | None = None, enable: bool = True, start: bool = True, dry_run: bool = False) → list[dict[str, Any]]

Install systemd units and .desktop launchers for every discovered PHOTON service.

photon_platform.clerk.service.launch_service_window(spec: photon_platform.clerk.config.ServiceSpec, *, new_window: bool = False, detach: bool = True, launcher_bin: str | None = None) → dict[str, Any]

Launch or raise spec inside a standalone GTK3/WebKit2GTK photon-app window.

photon_platform.clerk.service.render_services_toml(specs: list[photon_platform.clerk.config.ServiceSpec]) → str

Serialize service specifications to a clean documented services.toml file.

photon_platform.clerk.service.service_cmd() → None

Manage persistent systemd --user background services and .desktop launchers.