Documentation
¶
Overview ¶
Package config defines the on-disk JSON configuration for vigil, along with defaults, validation and atomic load/save helpers.
Index ¶
- Constants
- func ConfigDir(scope Scope) (string, error)
- func ConfigPath(scope Scope) (string, error)
- func ParseISODuration(s string) (time.Duration, error)
- func RuntimeDir(scope Scope) (string, error)
- func SettableKeys() []string
- func TokenPath(scope Scope) (string, error)
- type Clock
- type Config
- type ControlConfig
- type Engine
- type GraphConfig
- type InputConfig
- type InputMethod
- type LogConfig
- type ScheduleConfig
- type Scope
- type Window
Constants ¶
const CurrentVersion = 1
CurrentVersion is the config schema version written by this build. It allows future migrations to detect and upgrade older files.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
ConfigDir returns the directory that holds config.json for the given scope.
User scope follows the XDG convention on every OS (including macOS, where we deliberately use ~/.config rather than ~/Library/Application Support so the location is predictable and easy to find):
- $XDG_CONFIG_HOME/vigil if set
- Windows: %AppData%\vigil
- otherwise: ~/.config/vigil
func ConfigPath ¶
ConfigPath returns the absolute path to config.json for the given scope.
func ParseISODuration ¶
ParseISODuration parses the subset of ISO-8601 durations used by Microsoft Graph (days, hours, minutes, seconds — e.g. "PT8H", "P1DT2H30M"). Week, month and year designators are rejected because they are ambiguous as fixed durations.
func RuntimeDir ¶
RuntimeDir returns the directory used for mutable runtime artifacts: status.json, override.json, the single-instance lock, logs and the Graph token cache.
For user scope these live under the XDG state dir so an unprivileged CLI can always write the override file that the daemon watches:
- $XDG_STATE_HOME/vigil if set
- Windows: %LocalAppData%\vigil
- otherwise: ~/.local/state/vigil
For system scope they live alongside the system config (writable only by the service account / root) — see docs/configuration.md for the multi-user caveat.
func SettableKeys ¶
func SettableKeys() []string
SettableKeys returns the sorted list of supported dotted keys.
Types ¶
type Clock ¶
type Clock int
Clock is a wall-clock time of day expressed as minutes since midnight, in the range [0,1440).
func ParseClock ¶
ParseClock parses an "HH:MM" 24-hour string into a Clock.
type Config ¶
type Config struct {
Version int `json:"version"`
Engine Engine `json:"engine"`
Timezone string `json:"timezone"`
Schedule ScheduleConfig `json:"schedule"`
Input InputConfig `json:"input"`
Graph GraphConfig `json:"graph"`
Control ControlConfig `json:"control"`
Log LogConfig `json:"log"`
}
Config is the root configuration object persisted as config.json.
func Default ¶
func Default() Config
Default returns a Config populated with sensible defaults (Mon–Fri 08:00–17:00, synthetic-input engine).
func Load ¶
Load reads and validates the config at path. A missing file is reported via os.IsNotExist on the returned error so callers can offer `config init`.
func (Config) Location ¶
Location resolves the configured timezone. "Local" and "" map to time.Local.
func (*Config) SetField ¶
SetField sets a dotted key from a string and re-validates the whole config. On validation failure the config is left unchanged.
type ControlConfig ¶
type ControlConfig struct {
Port int `json:"port"`
}
ControlConfig configures the control plane. Port 0 means file-based control.
type Engine ¶
type Engine string
Engine selects which activation strategy (or strategies) the daemon runs.
type GraphConfig ¶
type GraphConfig struct {
TenantID string `json:"tenant_id"`
ClientID string `json:"client_id"`
Availability string `json:"availability"`
Activity string `json:"activity"`
Expiration string `json:"expiration"` // ISO-8601 duration, e.g. "PT8H"
RefreshMinutes int `json:"refresh_minutes"`
}
GraphConfig holds Microsoft Graph engine settings.
type InputConfig ¶
type InputConfig struct {
IntervalSeconds int `json:"interval_seconds"`
JitterSeconds int `json:"jitter_seconds"`
Method InputMethod `json:"method"`
PreventSleep bool `json:"prevent_sleep"`
// MovePixels is the maximum magnitude (px) of the mouse nudge; each tick
// uses a random 1..MovePixels offset and returns to origin.
MovePixels int `json:"move_pixels"`
}
InputConfig tunes the synthetic-input engine.
type InputMethod ¶
type InputMethod string
InputMethod selects how synthetic input is generated.
const ( // MethodMouse performs a small real relative mouse move (default, reliable). MethodMouse InputMethod = "mouse" // MethodKey presses a benign key (F15) that has no side effects. MethodKey InputMethod = "key" // MethodZen requests an invisible/zero-delta nudge. May be ignored by apps // that implement their own idle detection — opt-in only. MethodZen InputMethod = "zen" )
type LogConfig ¶
type LogConfig struct {
Level string `json:"level"`
MaxSizeMB int `json:"max_size_mb"`
MaxBackups int `json:"max_backups"`
}
LogConfig configures the rotating log file.
type ScheduleConfig ¶
type ScheduleConfig struct {
// Enabled turns schedule evaluation on. When false the daemon stays idle
// unless a manual override forces it active.
Enabled bool `json:"enabled"`
// Always keeps the daemon active whenever it runs, ignoring Windows.
Always bool `json:"always"`
// Windows are the active periods, evaluated in Config.Timezone.
Windows []Window `json:"windows"`
}
ScheduleConfig describes when the daemon should keep Teams active.
type Scope ¶
type Scope string
Scope determines whether files are resolved against per-user or system-wide (all users) locations.
type Window ¶
type Window struct {
Days []string `json:"days"` // e.g. ["Mon","Tue",...]; "Mon".."Sun"
Start string `json:"start"` // "HH:MM"
End string `json:"end"` // "HH:MM"
}
Window is a recurring weekly active period. Start/End are "HH:MM" 24h local times; an End that is not after Start denotes an overnight window.