config

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppDir added in v0.3.2

func AppDir(homeDir string) string

func ConfigDir

func ConfigDir(homeDir string) string

ConfigDir returns the path to the configuration directory.

func ConfigFilePath

func ConfigFilePath(homeDir string) string

ConfigFilePath returns the full path to pomati.yaml.

func DataDir

func DataDir(homeDir string) string

DataDir returns the path to the log directory.

func DbFilePath

func DbFilePath(homeDir string) string

DbFilePath returns the full path to pomati.yaml.

func LogDir

func LogDir(homeDir string) string

LogDir returns the path to the log directory.

func NotificationFilePath

func NotificationFilePath(homeDir string) string

NotificationFilePath returns the full path to pomati.yaml.

Types

type Config

type Config struct {
	ClockColor              string         `mapstructure:"clock_color"               yaml:"clock_color"`
	WorkDuration            int            `mapstructure:"work_duration"             yaml:"work_duration"`
	ShortBreakDuration      int            `mapstructure:"short_break_duration"      yaml:"short_break_duration"`
	LongBreakDuration       int            `mapstructure:"long_break_duration"       yaml:"long_break_duration"`
	NoNotification          bool           `mapstructure:"no_notification"           yaml:"no_notification"`
	NoSoundAlert            bool           `mapstructure:"no_sound_alert"            yaml:"no_sound_alert"`
	NoShortcutsNotification bool           `mapstructure:"no_shortcuts_notification" yaml:"no_shortcuts_notification"`
	WorkSoundAlertPath      string         `mapstructure:"work_sound_alert_path"     yaml:"work_sound_alert_path"`
	BreakSoundAlertPath     string         `mapstructure:"break_sound_alert_path"    yaml:"break_sound_alert_path"`
	Tags                    map[string]Tag `mapstructure:"tags"                      yaml:"tags"`
	DefaultTag              string         `mapstructure:"default_tag"               yaml:"default_tag"`
	HomeDir                 string         `mapstructure:"home_dir"                  yaml:"home_dir"`
}

Config represents the complete application configuration.

func New

func New() *Config

New creates a Config with sensible default values. The returned config is always valid and ready to use. Default values can be overridden using Option functions via Update().

func (*Config) EnsureSoundPaths

func (c *Config) EnsureSoundPaths() error

func (*Config) Hash

func (c *Config) Hash() string

Hash is used to see if important parts of config changed.

func (*Config) ToOptions

func (c *Config) ToOptions() []Option

ToOptions converts the persistent configuration fields to Option functions. Used for pomati.yaml round-trip (load from file, save to file). Only includes fields that should be persisted in pomati.yaml. Runtime-only fields (HomeDir) are excluded.

func (*Config) Update

func (c *Config) Update(opts []Option)

Update applies configuration options. This is the only way to modify Config after creation. Invalid options are silently ignored (warnings via gn.Warn()).

type Option

type Option func(*Config)

Option is a function that modifies Config. This is the functional options pattern.

func OptBreakSoundAlertPath

func OptBreakSoundAlertPath(s string) Option

OptBreakSoundAlertPath sets the audio file path for break completion alerts. Path may contain tilde for home directory.

func OptClockColor

func OptClockColor(s string) Option

OptClockColor sets the timer clock color. Accepts terminal color codes (0-255) or hex colors (e.g., "#ac8", "#eab920"). Invalid colors are logged and ignored.

func OptDefaultTag added in v0.3.2

func OptDefaultTag(s string) Option

OptDefaultTag sets the default tag.

func OptHomeDir

func OptHomeDir(s string) Option

OptHomeDir sets the home directory for config and log locations. Set once at startup from os.UserHomeDir(). Runtime-only field - not in ToOptions().

func OptLongBreakDuration

func OptLongBreakDuration(i int) Option

OptLongBreakDuration sets the long break duration in minutes (after every 4th tomato). Must be positive; invalid values are logged and ignored.

func OptNoNotification

func OptNoNotification(b bool) Option

OptNoNotification disables desktop notifications when true.

func OptNoShortcutsNotification added in v0.3.3

func OptNoShortcutsNotification(b bool) Option

OptNoShortcutsNotification disables the startup shortcuts notification when true. Other notifications still work.

func OptNoSoundAlert

func OptNoSoundAlert(b bool) Option

OptNoSoundAlert disables sound alerts when true.

func OptShortBreakDuration

func OptShortBreakDuration(i int) Option

OptShortBreakDuration sets the short break duration in minutes. Must be positive; invalid values are logged and ignored.

func OptTags added in v0.3.2

func OptTags(tags map[string]Tag) Option

OptTags sets the tag configurations.

func OptWorkDuration

func OptWorkDuration(i int) Option

OptWorkDuration sets the work session duration in minutes. Must be positive; invalid values are logged and ignored.

func OptWorkSoundAlertPath

func OptWorkSoundAlertPath(s string) Option

OptWorkSoundAlertPath sets the audio file path for work session completion alerts. Path may contain tilde for home directory.

type Tag added in v0.3.2

type Tag struct {
	Desc     string      `mapstructure:"desc"     yaml:"desc"`
	Emoji    string      `mapstructure:"emoji"    yaml:"emoji"`
	Triggers TagTriggers `mapstructure:"triggers" yaml:"triggers,omitempty"`
}

Tag represents a single tag configuration. Tags categorize tomatoes (e.g., "work", "home").

type TagTriggers added in v0.3.3

type TagTriggers struct {
	IPs   []string `mapstructure:"ips"   yaml:"ips,omitempty"`
	Times []string `mapstructure:"times" yaml:"times,omitempty"`
	Hosts []string `mapstructure:"hosts" yaml:"hosts,omitempty"`
}

TagTriggers defines conditions for automatic tag selection based on environment (hostname, IP address, time of day). All arrays use OR logic - any matching trigger activates the tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL