Documentation
¶
Overview ¶
Package config handles loading user configuration from ~/.config/cliamp/config.toml.
Index ¶
- func Save(key, value string) error
- func SaveNavidromeSort(sortType string) error
- type Config
- type EmbyConfig
- type JellyfinConfig
- type NavidromeConfig
- type NetEaseConfig
- type Overrides
- type PlayerConfig
- type PlaylistConfig
- type PlexConfig
- type QobuzConfig
- type SaveFunc
- type SoundCloudConfig
- type SpotifyConfig
- type YouTubeMusicConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Save ¶
Save updates only the given key in the existing config file, preserving all other content, comments, and formatting. If the key doesn't exist, it is appended. If no config file exists, one is created with just that key.
func SaveNavidromeSort ¶
SaveNavidromeSort persists the given album browse sort type to the [navidrome] section of the config file. It rewrites the browse_sort key in-place, or appends it after the [navidrome] section if not present. If no [navidrome] section exists, one is appended along with the key.
Types ¶
type Config ¶
type Config struct {
Volume float64 // dB, clamped at runtime to [VolumeMin, +6]
VolumeMin float64 // dB floor, range [-90, 0]; default -50
VisVolumeLinked bool // when true, visualizer bar height follows volume; default true
EQ [10]float64 // per-band gain in dB, range [-12, +12]
EQPreset string // preset name, or "" for custom
Repeat string // "off", "all", or "one"
Shuffle bool
Mono bool
Speed float64 // playback speed ratio: 0.25–2.0 (default 1.0)
AutoPlay bool // start playback automatically on launch (radio streams, CLI tracks)
SeekStepLarge int // seconds for Shift+Left/Right seek jumps
Provider string // default provider: "radio", "navidrome", "spotify", "qobuz", "plex", "jellyfin", "emby", "soundcloud", "netease", "ytmusic" (default "radio")
Theme string // theme name, or "" for ANSI default
Visualizer string // visualizer mode name, or "" for default (Bars)
SampleRate int // output sample rate: 22050, 44100, 48000, 96000, 192000
BufferMs int // speaker buffer in milliseconds (50–500)
ResampleQuality int // beep resample quality factor (1–4)
BitDepth int // PCM bit depth for FFmpeg output: 16 or 32
Compact bool // compact mode: cap frame width at 80 columns
PaddingH int // horizontal padding for the UI frame (default 3)
PaddingV int // vertical padding for the UI frame (default 1)
AudioDevice string // preferred audio output device name (empty = system default)
Playlist string // local TOML playlist name to load on startup
InitialDirectory string // initial directory for the file browser
Spotify SpotifyConfig // optional Spotify provider (requires Premium)
Qobuz QobuzConfig // optional Qobuz provider (requires subscription)
YouTubeMusic YouTubeMusicConfig // optional YouTube Music provider
Plex PlexConfig // optional Plex Media Server credentials
Jellyfin JellyfinConfig // optional Jellyfin server credentials
Emby EmbyConfig // optional Emby server credentials
SoundCloud SoundCloudConfig // SoundCloud provider (opt-in via enabled = true)
NetEase NetEaseConfig // NetEase Cloud Music provider (opt-in via enabled = true)
Plugins map[string]map[string]string // per-plugin config from [plugins.*] sections
LogLevel string // log level: debug, info, warn, error (default "info")
LowPower bool // reduce CPU by lowering UI cadence and disabling visualization
}
Config holds user preferences loaded from the config file.
func Load ¶
Load reads the config file from ~/.config/cliamp/config.toml. Returns defaults if the file does not exist.
func (Config) ApplyPlayer ¶
func (c Config) ApplyPlayer(p PlayerConfig)
ApplyPlayer applies audio-engine settings from the config.
func (Config) ApplyPlaylist ¶
func (c Config) ApplyPlaylist(pl PlaylistConfig)
ApplyPlaylist applies playlist-state settings from the config.
func (Config) SeekStepLargeDuration ¶
SeekStepLargeDuration returns the configured Shift+Left/Right seek jump.
type EmbyConfig ¶
type EmbyConfig struct {
URL string // e.g. "https://emby.example.com"
Token string // API access token
User string // optional username for password-based login
Password string // optional password for password-based login
UserID string // optional user id to skip discovery via /Users/Me
}
EmbyConfig holds credentials for an Emby server. URL is required. Authenticate either with Token, or with User+Password. UserID is optional and can be discovered lazily.
func (EmbyConfig) IsSet ¶
func (e EmbyConfig) IsSet() bool
IsSet reports whether the Emby provider is configured.
type JellyfinConfig ¶
type JellyfinConfig struct {
URL string // e.g. "https://jellyfin.example.com"
Token string // API access token
User string // optional username for password-based login
Password string // optional password for password-based login
UserID string // optional user id to skip discovery via /Users/Me
}
JellyfinConfig holds credentials for a Jellyfin server. URL is required. Authenticate either with Token, or with User+Password. UserID is optional and can be discovered lazily.
func (JellyfinConfig) IsSet ¶
func (j JellyfinConfig) IsSet() bool
IsSet reports whether the Jellyfin provider is configured.
type NavidromeConfig ¶
type NavidromeConfig struct {
}
NavidromeConfig holds credentials for a Navidrome/Subsonic server. All three fields must be non-empty for a client to be constructed.
func (NavidromeConfig) IsSet ¶
func (n NavidromeConfig) IsSet() bool
IsSet reports whether all three Navidrome credentials are present.
type NetEaseConfig ¶
type NetEaseConfig struct {
Enabled bool // true only when user explicitly sets enabled = true
CookiesFrom string // browser name for account APIs and playback (e.g. "chrome")
UserID string // optional account user id; setup can discover this from cookies
}
NetEaseConfig holds settings for the NetEase Cloud Music provider. The provider is opt-in and can reuse an existing browser session through yt-dlp's --cookies-from-browser support.
func (NetEaseConfig) IsSet ¶
func (n NetEaseConfig) IsSet() bool
IsSet reports whether the NetEase provider should be shown.
type Overrides ¶
type Overrides struct {
Volume *float64
Shuffle *bool
Repeat *string
Mono *bool
Provider *string
Theme *string
Visualizer *string
EQPreset *string
SampleRate *int
BufferMs *int
ResampleQuality *int
BitDepth *int
Play *bool
Compact *bool
AudioDevice *string
Playlist *string
LogLevel *string
LowPower *bool
}
Overrides holds CLI flag values. Nil pointers mean "not set".
type PlayerConfig ¶
type PlayerConfig interface {
SetVolumeMin(db float64)
SetVolume(db float64)
SetSpeed(ratio float64)
SetEQBand(band int, dB float64)
ToggleMono()
}
PlayerConfig is the subset of player controls needed to apply config.
type PlaylistConfig ¶
type PlaylistConfig interface {
CycleRepeat()
ToggleShuffle()
}
PlaylistConfig is the subset of playlist controls needed to apply config.
type PlexConfig ¶
type PlexConfig struct {
URL string // e.g. "http://192.168.1.10:32400"
Token string // X-Plex-Token
Libraries []string // optional: restrict to these music library names
}
PlexConfig holds credentials for a Plex Media Server. Both URL and Token must be non-empty for a client to be constructed.
func (PlexConfig) IsSet ¶
func (p PlexConfig) IsSet() bool
IsSet reports whether both Plex credentials are present.
type QobuzConfig ¶
type QobuzConfig struct {
Disabled bool // true only when user explicitly sets enabled = false
Enabled bool // true when [qobuz] section exists
Quality int // preferred stream format_id: 5 (MP3 320), 6 (FLAC CD), 7 (Hi-Res <=96kHz), 27 (Hi-Res <=192kHz)
}
QobuzConfig holds settings for the Qobuz provider. Requires a paid Qobuz subscription (Studio/Sublime). The app_id, signing secrets and OAuth private key are scraped automatically from the Qobuz web player, so no developer credentials are needed. Sign-in is an interactive OAuth browser flow.
func (QobuzConfig) IsSet ¶
func (q QobuzConfig) IsSet() bool
IsSet reports whether the Qobuz provider should be shown. Section presence is enough; credentials are scraped from the Qobuz web player automatically.
type SaveFunc ¶
type SaveFunc struct{}
SaveFunc wraps the package-level Save function as a method, satisfying the ui/model.ConfigSaver interface.
type SoundCloudConfig ¶
type SoundCloudConfig struct {
Enabled bool // true only when user explicitly sets enabled = true
User string // SoundCloud username for browse (optional)
CookiesFrom string // browser name for yt-dlp --cookies-from-browser (optional)
}
SoundCloudConfig holds settings for the SoundCloud provider. SoundCloud is opt-in: requires enabled = true in [soundcloud] before the provider registers. Setting User exposes that profile's Tracks/Likes/Reposts in the browse view. Setting CookiesFrom (browser name) lets yt-dlp use the user's signed-in session for subscriber-gated tracks.
func (SoundCloudConfig) IsSet ¶
func (s SoundCloudConfig) IsSet() bool
IsSet reports whether the SoundCloud provider should be shown.
type SpotifyConfig ¶
type SpotifyConfig struct {
Disabled bool // true only when user explicitly sets enabled = false
Enabled bool // true when [spotify] section exists (even without client_id)
ClientID string // Spotify Developer app client ID (overrides built-in fallback)
Bitrate int // preferred Spotify stream bitrate in kbps
}
SpotifyConfig holds settings for the Spotify provider. Requires a Spotify Premium account. If client_id is empty, a built-in fallback (the librespot keymaster ID) is used so search and catalog endpoints work even for users who never registered their own developer app — see Spotify's Nov 27, 2024 dev-mode quota restriction.
func (SpotifyConfig) IsSet ¶
func (s SpotifyConfig) IsSet() bool
IsSet reports whether the Spotify provider should be shown. Section presence is enough — a built-in fallback client_id is used when none is configured.
func (SpotifyConfig) ResolveClientID ¶
func (s SpotifyConfig) ResolveClientID(fallbackID string) string
ResolveClientID returns the user's configured client_id, or fallbackID when none is set.
type YouTubeMusicConfig ¶
type YouTubeMusicConfig struct {
Disabled bool // true only when user explicitly sets enabled = false
Enabled bool // true when [ytmusic] section exists (even without credentials)
ClientID string // Google Cloud OAuth2 client ID (overrides built-in fallback)
ClientSecret string // Google Cloud OAuth2 client secret (overrides built-in fallback)
CookiesFrom string // browser name for yt-dlp --cookies-from-browser (e.g. "chrome", "firefox")
}
YouTubeMusicConfig holds settings for the YouTube Music provider. If no client_id/client_secret are set, built-in fallback credentials are used automatically (same pattern as Spotify).
func (YouTubeMusicConfig) IsSetOrFallback ¶
func (y YouTubeMusicConfig) IsSetOrFallback(fallbackFn func() (string, string)) bool
IsSetOrFallback returns true when YouTube providers should be enabled, either via config or because fallback credentials are available.
func (YouTubeMusicConfig) ResolveCredentials ¶
func (y YouTubeMusicConfig) ResolveCredentials(fallbackFn func() (string, string)) (clientID, clientSecret string)
ResolveCredentials returns the user's configured credentials, or falls back to the built-in pool. Returns empty strings only when the pool is also empty.