Documentation
¶
Overview ¶
Package config centralizes OpenDeezer's user configuration (env vars + ~/.config/opendeezer files) for the bits shared between the TUI and the GUI engine (corelib): the control API and Discord Rich Presence settings.
Index ¶
- func DefaultDownloadDir() string
- func Dir() (string, error)
- func IsLoopbackAddr(addr string) bool
- func LanguageSetting() string
- func LoadAdsDisabled() bool
- func LoadDiscordAppID() string
- func LoadDownloadDir() string
- func LoadLanguage() string
- func LoadPeers() []string
- func NormalizePeer(addr string) (base, hostport string)
- func PeerHostPorts() []string
- func SaveAdsDisabled(disabled bool) error
- func SaveControlEnabled(enabled bool, addr string) error
- func SaveControlToken(token string) error
- func SaveDownloadDir(path string) error
- func SaveEQ(eq EQ) error
- func SaveLanguage(code string) error
- func SaveMedia(m Media) error
- func SetBaseDir(dir string)
- type Control
- type EQ
- type Media
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDownloadDir ¶
func DefaultDownloadDir() string
DefaultDownloadDir is where downloaded tracks land when the user hasn't chosen a folder: <home>/Music/OpenDeezer, falling back to <home>/Downloads/OpenDeezer and finally "OpenDeezer" in the working directory. Shared across every client so the default is identical everywhere.
func IsLoopbackAddr ¶
IsLoopbackAddr reports whether a host:port binds only the loopback interface.
func LanguageSetting ¶
func LanguageSetting() string
LanguageSetting returns ONLY the persisted language file (~/.config/opendeezer/ language.txt), ignoring $OPENDEEZER_LANG. LoadLanguage lets the env var win so a forced locale applies everywhere at startup; the in-app Language menu, however, edits and displays its own persisted selection, so it must read the file alone — otherwise a set OPENDEEZER_LANG would freeze the menu on one entry and desync its label from the locale actually applied.
func LoadAdsDisabled ¶
func LoadAdsDisabled() bool
LoadAdsDisabled reports whether the user has opted out of Deezer Free's play-reporting/ads, from $OPENDEEZER_DISABLE_ADS or ~/.config/opendeezer/ads-disabled.txt. Default false (ads/reporting on). This only affects free accounts; it is the user's explicit, at-own-risk choice (see deezer.SetAdsDisabled for the tradeoff). Shared across every client.
func LoadDiscordAppID ¶
func LoadDiscordAppID() string
LoadDiscordAppID returns the Discord application id for Rich Presence, from $OPENDEEZER_DISCORD_APP_ID or ~/.config/opendeezer/discord-app-id.txt. Empty disables the feature.
func LoadDownloadDir ¶
func LoadDownloadDir() string
LoadDownloadDir returns the folder downloaded tracks are saved to, from $OPENDEEZER_DOWNLOAD_DIR, then ~/.config/opendeezer/download-dir.txt, then DefaultDownloadDir. Shared by the TUI and every GUI so a folder chosen in one client applies everywhere.
func LoadLanguage ¶
func LoadLanguage() string
LoadLanguage returns the persisted UI language code (e.g. "fr", "zh"), from $OPENDEEZER_LANG or ~/.config/opendeezer/language.txt. An empty result means "auto" — the caller should fall back to locale detection. Shared across every client so the language chosen in one place (TUI, GUI) applies everywhere.
func LoadPeers ¶
func LoadPeers() []string
LoadPeers returns manually-configured Connect peer addresses (host[:port]), from $OPENDEEZER_CONNECT_PEERS (comma-separated) and ~/.config/opendeezer/connect-peers.txt (one per line). These are merged into the device picker alongside LAN discovery, so Connect works over networks that carry no multicast/broadcast (e.g. Tailscale/VPN — unicast-only meshes).
func NormalizePeer ¶
NormalizePeer turns user input ("host", "host:port", "http://host:port") into a base URL + host:port, defaulting the port to 7654. Returns ("","") if empty.
func PeerHostPorts ¶
func PeerHostPorts() []string
PeerHostPorts returns the configured Connect peers (LoadPeers) normalized to host:port form, for passing to discovery.Discover as unicast probe targets so static peers answer even on multicast-filtered networks.
func SaveAdsDisabled ¶
SaveAdsDisabled persists the free-tier ads opt-out.
func SaveControlEnabled ¶
SaveControlEnabled persists whether the control API starts automatically, so a Settings UI can flip it without editing env vars or config files by hand. addr is the bind address to remember while enabled (typically the current LoadControl().Addr); pass "" to disable.
func SaveControlToken ¶
SaveControlToken persists the control-API bearer token. "" clears it, which falls back to same-account auth on a LAN bind.
func SaveDownloadDir ¶
SaveDownloadDir persists the download folder. "" clears it (back to the default).
func SaveLanguage ¶
SaveLanguage persists the UI language code. "" clears it (back to auto).
func SaveMedia ¶
SaveMedia persists the media settings to media.json in the config dir, clamping a negative cache size to 0 (disabled) first.
func SetBaseDir ¶ added in v3.1.3
func SetBaseDir(dir string)
SetBaseDir overrides the directory Dir returns. Hosts whose platform os.UserConfigDir is not a writable, persistent path — Android and iOS, where it resolves outside the app sandbox — must call this once at startup with an app-private directory, otherwise settings (media.json, tokens) and on-disk caches can't be saved or don't survive a relaunch. "" restores the default.
Types ¶
type Control ¶
type Control struct {
Enabled bool
Addr string // host:port; "" -> 127.0.0.1:7654
Token string // bearer token ("" = no auth, localhost only)
SameAccount bool // require a matching Deezer account when no token (LAN)
}
Control holds the control-API settings (remote control + MCP).
func LoadControl ¶
func LoadControl() Control
LoadControl reads the control-API config from $OPENDEEZER_CONTROL ("1"/addr) + $OPENDEEZER_CONTROL_TOKEN, else ~/.config/opendeezer/{control.txt,control-token.txt}.
type EQ ¶
type EQ struct {
Enabled bool `json:"enabled"`
Mono bool `json:"mono"`
PreampDB float64 `json:"preampDb"`
GainsDB []float64 `json:"gainsDb"`
Preset string `json:"preset"`
}
EQ is the persisted equalizer + mono-downmix state. It is loaded and saved by the audio engine itself (not per client), so the TUI, every GUI and the control API all share one set of settings through ~/.config/opendeezer.
type Media ¶
type Media struct {
// MediaCacheMB is the on-disk raw-stream cache budget in megabytes
// (see internal/mediacache). 0 — the default — disables the cache
// entirely; negative values are clamped to 0.
MediaCacheMB int `json:"mediaCacheMB"`
}
Media is the persisted media/streaming configuration (media.json in the config dir), shared across every client like EQ. Its zero value is the default behavior: no on-disk stream cache.