Add Linux desktop integration that installs a user-level .desktop file and icon under XDG data directories so taskbars can match the PySentry window to the application icon. Pass the installed icon path into Linux autostart desktop entries when available, while keeping the Windows and fallback autostart APIs compatible. Bump the application version to 0.2.2, update README artifact examples, and record the release notes in docs/CHANGELOG.md. Also adjust the Mermaid architecture diagram so Gitea can render it without invalid SVG line-break tags.
2.8 KiB
PySentry Architecture
This document shows the current component interaction model. PySentry is still a single desktop process: the GUI, scheduler, storage, and command runner live in one application and communicate through Go function calls and shared in-memory job state.
Component Diagram
flowchart LR
user["Desktop user"]
gui["src/gui - Fyne windows, tabs, dialogs"]
store["src/core Store - YAML config and jobs"]
scheduler["src/core Scheduler - @every and cron timing"]
runner["src/core Runner - shell command execution"]
autostart["src/core Autostart - Windows Run / Linux desktop startup"]
config["pysentry.yaml - application settings"]
jobs["jobs.yaml - job definitions"]
logs["logs_dir - per-run command output logs"]
shell["Platform shell - cmd.exe /C or sh -c"]
user -->|"edits jobs, settings, runs commands"| gui
gui -->|"OpenStore, SaveConfig, SaveJobs"| store
store -->|"read/write"| config
store -->|"read/write"| jobs
gui -->|"Start, Pause, RunNow, RefreshSchedule"| scheduler
scheduler -->|"SaveJobs after state changes"| store
scheduler -->|"RunJob(trigger)"| runner
runner -->|"execute command"| shell
runner -->|"write stdout/stderr log"| logs
runner -->|"RunRecord with status, duration, log path"| scheduler
scheduler -->|"onChange RunRecord"| gui
gui -->|"display History, command output, job state"| user
gui -->|"SetAutostart, AutostartStatus"| autostart
autostart -->|"use executable path from resolved Paths"| config
Main Flows
-
Startup: The executable starts
cmd/pysentry, which calls the GUI package. The GUI opens the store, loadspysentry.yamlandjobs.yaml, creates the main tabs, then starts the scheduler with the loaded job slice. -
Editing settings or jobs: The GUI updates the in-memory job/config state and asks
Storeto write YAML back to disk. Job definitions stay in onejobs.yaml; runtime command output is not stored there. -
Scheduled run:
Schedulerchecks due jobs on a one-second ticker. When a job is due, it marks the job as running, saves state, and startsRunnerasynchronously. -
Manual run:
Run nowcalls the same scheduler path as scheduled execution, but the resulting history record uses theManualtrigger. -
Command execution:
Runnerexecutes the command through the platform shell, captures stdout and stderr, writes one timestamped.logfile, and returns aRunRecord. -
History update: The scheduler receives the
RunRecord, updates the matching job, saves YAML, runs log cleanup, and calls the GUI callback so theHistorytab refreshes. -
Autostart: The Settings tab calls the platform autostart implementation. Windows uses the current user's Run registry key. Linux uses a desktop-session startup entry.