config

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config handles loading and validating the kcd daemon configuration. It has zero external imports except github.com/BurntSushi/toml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the default config file path.

func DefaultSocketPath added in v1.0.5

func DefaultSocketPath() string

DefaultSocketPath returns the default IPC socket path.

func StatePath

func StatePath() string

StatePath returns the path to the device state file.

Types

type BatteryConfig added in v1.10.0

type BatteryConfig struct {
	NotifyLow   bool   `toml:"notify_low"`
	NotifyFull  bool   `toml:"notify_full"`
	LowUrgency  string `toml:"low_urgency"`
	FullUrgency string `toml:"full_urgency"`
	LowMessage  string `toml:"low_message"`
	FullMessage string `toml:"full_message"`
}

func (*BatteryConfig) Defaults added in v1.10.0

func (c *BatteryConfig) Defaults()

type Config

type Config struct {
	DeviceID    string `toml:"device_id"`
	DeviceName  string `toml:"device_name"`
	DeviceType  string `toml:"device_type"` // "desktop", "laptop", "phone", "tablet"
	CertFile    string `toml:"cert_file"`
	KeyFile     string `toml:"key_file"`
	SocketPath  string `toml:"socket_path"`
	DownloadDir string `toml:"download_dir"`
	TCPPort     int    `toml:"tcp_port"`
	// EnableBroadcast was removed — broadcast starts automatically with `kcd pair` (listen mode)
	LogLevel string `toml:"log_level"` // "debug", "info", "warn", "error" (or "quiet")
	// AutoAcceptPairing was removed in favor of `kcd pair` (listen mode).
	// Old config values are silently ignored by the TOML parser.
	Plugins       PluginConfig             `toml:"plugins"`
	Commands      map[string]string        `toml:"commands"`
	Notifications NotificationConfig       `toml:"notifications"`
	Battery       BatteryConfig            `toml:"battery"`
	Notification  NotificationPluginConfig `toml:"notification_plugin"`
	Share         ShareConfig              `toml:"share"`
	SFTP          SFTPConfig               `toml:"sftp"`
	Ping          PingConfig               `toml:"ping"`
	Pairing       PairingConfig            `toml:"pairing"`
	Mousepad      MousepadConfig           `toml:"mousepad"`
	SMS           SMSConfig                `toml:"sms"`
	ConfigPath    string                   `toml:"-"` // populated at load time, never written to disk
}

Config holds all daemon configuration.

func Defaults

func Defaults() *Config

Defaults returns a Config populated with sensible defaults using XDG paths.

func Load

func Load(path string) (*Config, error)

Load reads a TOML config file and merges it with defaults.

func (*Config) EnsureDeviceID

func (c *Config) EnsureDeviceID(configPath string) error

EnsureDeviceID generates a UUIDv4-style device ID if one is not already set, and writes the updated config back to the given path.

func (*Config) Save

func (c *Config) Save(path string) error

Save writes the config to a TOML file, creating parent directories as needed.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks required fields and returns an error if any are invalid.

type MousepadConfig added in v1.10.0

type MousepadConfig struct {
	Backend string `toml:"backend"`
}

func (*MousepadConfig) Defaults added in v1.10.0

func (c *MousepadConfig) Defaults()

type NotificationConfig added in v1.0.5

type NotificationConfig map[string]string

NotificationConfig controls per-app notification filtering.

type NotificationPluginConfig added in v1.10.0

type NotificationPluginConfig struct {
	Urgency          string `toml:"urgency"`
	FetchIcons       bool   `toml:"fetch_icons"`
	IconCacheDir     string `toml:"icon_cache_dir"`
	MaxBodyLength    int    `toml:"max_body_length"`
	ExpireMS         int    `toml:"expire_ms"`
	SkipNonClearable bool   `toml:"skip_non_clearable"`
}

func (*NotificationPluginConfig) Defaults added in v1.10.0

func (c *NotificationPluginConfig) Defaults()

type PairingConfig added in v1.10.0

type PairingConfig struct {
	TimeoutSecs int `toml:"timeout_secs"`
}

func (*PairingConfig) Defaults added in v1.10.0

func (c *PairingConfig) Defaults()

type PingConfig added in v1.10.0

type PingConfig struct {
	AppName        string `toml:"app_name"`
	Icon           string `toml:"icon"`
	DefaultMessage string `toml:"default_message"`
}

func (*PingConfig) Defaults added in v1.10.0

func (c *PingConfig) Defaults()

type PluginConfig

type PluginConfig struct {
	Battery        bool `toml:"battery"`
	Clipboard      bool `toml:"clipboard"`
	Notification   bool `toml:"notification"`
	Share          bool `toml:"share"`
	RunCommand     bool `toml:"runcommand"`
	MPRIS          bool `toml:"mpris"`
	Ping           bool `toml:"ping"`
	Telephony      bool `toml:"telephony"`
	Connectivity   bool `toml:"connectivity"`
	Mousepad       bool `toml:"mousepad"`
	SFTP           bool `toml:"sftp"`
	FindMyPhone    bool `toml:"findmyphone"`
	LockDevice     bool `toml:"lockdevice"`
	SystemVolume   bool `toml:"systemvolume"`
	PauseMusic     bool `toml:"pausemusic"`
	SMS            bool `toml:"sms"`
	Presenter      bool `toml:"presenter"`
	FindThisDevice bool `toml:"findthisdevice"`
}

func (*PluginConfig) Defaults added in v1.10.0

func (p *PluginConfig) Defaults()

type SFTPConfig added in v1.10.0

type SFTPConfig struct {
	MountDir               string   `toml:"mount_dir"`
	CredentialsTimeoutSecs int      `toml:"credentials_timeout_secs"`
	KeepaliveIntervalSecs  int      `toml:"keepalive_interval_secs"`
	KeepaliveCount         int      `toml:"keepalive_count"`
	AutoOpen               bool     `toml:"auto_open"`
	OpenCommand            string   `toml:"open_command"`
	ExtraSshfsOpts         []string `toml:"extra_sshfs_opts"`
}

func (*SFTPConfig) Defaults added in v1.10.0

func (c *SFTPConfig) Defaults()

type SMSConfig added in v1.11.0

type SMSConfig struct {
	// NotifyIncoming shows a desktop notification when an SMS is received.
	NotifyIncoming bool `toml:"notify_incoming"`
}

func (*SMSConfig) Defaults added in v1.11.0

func (c *SMSConfig) Defaults()

type ShareConfig added in v1.10.0

type ShareConfig struct {
	PortMin           int    `toml:"port_min"`
	PortMax           int    `toml:"port_max"`
	AcceptTimeoutSecs int    `toml:"accept_timeout_secs"`
	AutoOpen          bool   `toml:"auto_open"`
	OpenCommand       string `toml:"open_command"`
	Overwrite         bool   `toml:"overwrite"`
}

func (*ShareConfig) Defaults added in v1.10.0

func (c *ShareConfig) Defaults()

Jump to

Keyboard shortcuts

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