Documentation
¶
Index ¶
Constants ¶
const DefaultAFKThreshold = 300
DefaultAFKThreshold is the default idle-time threshold in seconds.
const DefaultVolume = 100
DefaultVolume is the default playback volume (0-100).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct {
CooldownSeconds int `json:"cooldown_seconds,omitempty"`
Steps []Step `json:"steps"`
}
Action holds an ordered list of steps to execute.
type Config ¶
type Config struct {
Options Options `json:"config"`
Profiles map[string]Profile `json:"profiles"`
}
Config holds the top-level configuration: global options and profiles.
func Load ¶
Load reads and parses a config file. It tries, in order:
- explicitPath (if non-empty)
- notify-config.json next to the running binary
- ~/.config/notify/notify-config.json
func (*Config) UnmarshalJSON ¶
UnmarshalJSON sets defaults then decodes the JSON structure. Go's json.Unmarshal merges into existing struct fields, so only values present in JSON override the defaults.
type Credentials ¶
type Credentials struct {
DiscordWebhook string `json:"discord_webhook,omitempty"`
SlackWebhook string `json:"slack_webhook,omitempty"`
TelegramToken string `json:"telegram_token,omitempty"`
TelegramChatID string `json:"telegram_chat_id,omitempty"`
}
Credentials holds secret values for remote notification actions.
func MergeCredentials ¶ added in v0.2.13
func MergeCredentials(global Credentials, profile *Credentials) Credentials
MergeCredentials returns global credentials with any non-empty profile fields overriding. A nil profile returns global unchanged.
type Options ¶
type Options struct {
AFKThresholdSeconds int `json:"afk_threshold_seconds,omitempty"`
DefaultVolume int `json:"default_volume,omitempty"`
Log bool `json:"log,omitempty"`
Echo bool `json:"echo,omitempty"`
Cooldown bool `json:"cooldown,omitempty"`
CooldownSeconds int `json:"cooldown_seconds,omitempty"`
ExitCodes map[string]string `json:"exit_codes,omitempty"`
Credentials Credentials `json:"credentials,omitempty"`
}
Options holds global settings parsed from the "config" key.
type Profile ¶
type Profile struct {
Extends string `json:"-"`
Aliases []string `json:"-"`
Credentials *Credentials `json:"-"`
Actions map[string]Action `json:"-"`
}
Profile holds a set of actions and an optional parent profile name. When "extends" is set, the profile inherits all actions from the parent, with its own actions taking priority on conflicts. Aliases provide shorthand names for the profile. Credentials override global credentials field-by-field (nil = use global only).
func (*Profile) UnmarshalJSON ¶ added in v0.2.11
UnmarshalJSON extracts the optional "extends" key and parses all remaining keys as actions. This keeps the JSON format flat:
{ "extends": "default", "ready": { "steps": [...] } }
type Step ¶
type Step struct {
Type string `json:"type"` // "sound" | "say" | "toast" | "discord" | "discord_voice" | "slack" | "telegram" | "telegram_audio" | "telegram_voice" | "webhook"
Sound string `json:"sound,omitempty"` // type=sound
Text string `json:"text,omitempty"` // type=say, discord, discord_voice, slack, telegram, telegram_audio, webhook
Title string `json:"title,omitempty"` // type=toast
Message string `json:"message,omitempty"` // type=toast
URL string `json:"url,omitempty"` // type=webhook
Headers map[string]string `json:"headers,omitempty"` // type=webhook
Volume *int `json:"volume,omitempty"` // per-step override, nil = use default
When string `json:"when,omitempty"` // "" | "never" | "afk" | "present" | "run" | "direct" | "hours:X-Y"
}
Step is a single unit of work within an action.