config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 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 StatePath

func StatePath() string

StatePath returns the path to the device state file.

Types

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   bool              `toml:"enable_broadcast"`    // Toggle UDP discovery broadcast
	LogLevel          string            `toml:"log_level"`           // "debug", "info", "warn", "error" (or "quiet")
	AutoAcceptPairing bool              `toml:"auto_accept_pairing"` // Auto-accept incoming pair requests (headless mode)
	Plugins           PluginConfig      `toml:"plugins"`
	Commands          map[string]string `toml:"commands"` // key → shell command for RunCommand plugin
}

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 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"`
	SendNotifications bool `toml:"sendnotifications"`
	SMS               bool `toml:"sms"`
}

PluginConfig toggles individual plugins on or off.

Jump to

Keyboard shortcuts

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