config

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config manages pixeltui's JSON config file at <dataDir>/config.json. It supports a setup wizard (Save) plus env-var overrides at load time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path(dataDir string) string

Path returns the config file path for the given data directory.

Types

type Config

type Config struct {
	LastfmKey   string   `json:"lastfm_key"`
	Subsonic    Subsonic `json:"subsonic"`
	LocalDirs   []string `json:"local_dirs"`   // folders of local audio files
	DownloadDir string   `json:"download_dir"` // where downloads are saved
	Theme       string   `json:"theme"`        // accent theme name (default if empty)
	Explore     int      `json:"explore"`      // 0..10, default 5
	Autoplay    bool     `json:"autoplay"`     // default true
}

Config is the persisted application configuration.

func Default

func Default() *Config

Default returns a Config with sensible defaults (Explore=5, Autoplay=true).

func Load

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

Load reads <dataDir>/config.json and overlays environment variables (env wins). A missing or malformed file is non-fatal: it falls back to Default() then applies env. It returns an error only for unexpected IO failures.

func (*Config) HasLocal

func (c *Config) HasLocal() bool

HasLocal reports whether any local directories are configured.

func (*Config) HasSubsonic

func (c *Config) HasSubsonic() bool

HasSubsonic reports whether a Subsonic URL is configured.

func (*Config) Save

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

Save writes the config as pretty-printed JSON atomically (temp file + rename), creating dataDir if needed. The dir is 0700 and the file 0600 since it can hold a password.

type Subsonic

type Subsonic struct {
	URL  string `json:"url"`
	User string `json:"user"`
	Pass string `json:"pass"`
}

Subsonic holds credentials for a Subsonic-compatible server.

Jump to

Keyboard shortcuts

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