config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config manages the tuify config file. It resolves the platform-appropriate directory (respecting XDG_CONFIG_HOME on Unix-likes), loads and validates the on-disk JSON, and writes updates with safe permissions.

The zero-value Config is not usable — callers construct a Config via Load (existing file) or first-time setup in bootstrap, then call Validate before handing it off. Dir is exported so other packages (auth, librespot cache, debug log) can place their files next to config.json without re-implementing the platform-choice logic.

Index

Constants

View Source
const DefaultRedirectURL = "http://127.0.0.1:4444/callback"

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir returns the tuify config directory. Honors $XDG_CONFIG_HOME, otherwise derives from the user's home directory. Returns an error if neither is available — silently defaulting to an empty path meant every downstream "failed to open" error pointed at a phantom file at the repo root.

func Save

func Save(cfg *Config) error

Types

type Config

type Config struct {
	ClientID        string `json:"client_id"`
	EnableLibrespot bool   `json:"enable_librespot,omitempty"`
	LibrespotPath   string `json:"librespot_path,omitempty"`
	DeviceName      string `json:"device_name,omitempty"`
	Bitrate         int    `json:"bitrate,omitempty"`
	SpotifyUsername string `json:"spotify_username,omitempty"`
	RedirectURL     string `json:"redirect_url,omitempty"`
	AudioBackend    string `json:"audio_backend,omitempty"`
	VimMode         bool   `json:"vim_mode,omitempty"`
	// Appearance forces dark or light palette selection. Empty (omitted)
	// uses lipgloss's terminal-background autodetection. Valid: "", "dark",
	// "light".
	Appearance string      `json:"appearance,omitempty"`
	Theme      theme.Theme `json:"theme,omitzero"`
}

func Load

func Load() (*Config, error)

func (*Config) Validate added in v0.2.0

func (c *Config) Validate() error

Validate checks that configured values are valid. Zero values (omitted fields) are not checked — defaults are applied elsewhere.

Jump to

Keyboard shortcuts

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