ui

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Overview

Package ui is the Bubble Tea TUI for OpenDeezer: a menu/list browser with an always-visible now-playing footer. Network calls run as tea.Cmds.

Index

Constants

This section is empty.

Variables

View Source
var Version = version.Number

Version is the app version, set from main at startup (defaults to the release number so library users get the right value without main).

Functions

func LoadARL

func LoadARL() string

LoadARL resolves the Deezer ARL from, in order: $DEEZER_ARL, then ~/.config/opendeezer/arl.txt. Returns "" if neither is set.

func LoadAudioDevice added in v0.4.0

func LoadAudioDevice() string

LoadAudioDevice / SaveAudioDevice persist the selected output device id.

func LoadCrossfadeMS added in v0.4.0

func LoadCrossfadeMS() int

LoadCrossfadeMS / SaveCrossfadeMS persist the crossfade duration in ms.

func LoadDiscordAppID added in v1.0.0

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 LoadGapless added in v0.4.0

func LoadGapless() bool

LoadGapless / SaveGapless persist the gapless toggle (default: on).

func LoadLastPeer added in v1.0.0

func LoadLastPeer() string

LoadLastPeer / SaveLastPeer remember the last remote-control peer address so the connect screen can prefill it.

func LoadQuality

func LoadQuality() int

LoadQuality reads the persisted quality level: 0=Normal, 1=High, 2=HiFi.

func LoadReplayGain added in v0.3.0

func LoadReplayGain() bool

LoadReplayGain / SaveReplayGain persist the loudness-normalization toggle.

func LoadTheme added in v0.3.0

func LoadTheme() string

LoadTheme returns the saved theme name ("" if none).

func SaveARL

func SaveARL(arl string) error

SaveARL writes the ARL to ~/.config/opendeezer/arl.txt (0600).

func SaveAudioDevice added in v0.4.0

func SaveAudioDevice(id string) error

func SaveCrossfadeMS added in v0.4.0

func SaveCrossfadeMS(ms int) error

func SaveGapless added in v0.4.0

func SaveGapless(v bool) error

func SaveLastPeer added in v1.0.0

func SaveLastPeer(addr string) error

func SaveQuality

func SaveQuality(level int) error

SaveQuality persists the quality level (0..2).

func SaveReplayGain added in v0.3.0

func SaveReplayGain(v bool) error

func SaveResume added in v0.3.0

func SaveResume(t deezer.Track, positionMS int64) error

SaveResume writes the current track + position to resume.json. Positions in the first few seconds are treated as "start over" and clear the state.

func SaveTheme added in v0.3.0

func SaveTheme(name string) error

SaveTheme persists the theme name.

Types

type ControlConfig added in v1.0.0

type ControlConfig 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)
}

ControlConfig holds the control-API settings (remote control + MCP).

func LoadControl added in v1.0.0

func LoadControl() ControlConfig

LoadControl reads the control-API config: $OPENDEEZER_CONTROL ("1"/addr) + $OPENDEEZER_CONTROL_TOKEN, else ~/.config/opendeezer/{control.txt,control-token.txt}.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the root Bubble Tea model.

func New

func New(client *deezer.Client, player *audio.Player) *Model

New builds the root model.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init kicks off login + the UI tick. The update check runs alongside them in the background (see updatecheck.go) and never delays startup.

func (*Model) StartControl added in v1.0.0

func (m *Model) StartControl(send func(tea.Msg)) error

StartControl starts the control API (remote control + MCP) if enabled in the config. Commands arrive as controlCmdMsg via send so they run on the update loop; status is served from an atomic snapshot refreshed by publishControl. Returns nil (no error) when the API is disabled. Call after tea.NewProgram.

func (*Model) StartMedia

func (m *Model) StartMedia(send func(tea.Msg))

StartMedia wires OS media controls (MPRIS) to the running program. Commands from the desktop are delivered as mediaCmdMsg via the program's Send so they run on the Bubble Tea update loop. Call after tea.NewProgram, before Run.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles all messages.

func (*Model) View

func (m *Model) View() string

View renders the whole screen.

type ResumeState added in v0.3.0

type ResumeState struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	ArtistLine string `json:"artistLine"`
	AlbumName  string `json:"albumName"`
	ArtworkURL string `json:"artworkUrl"`
	DurationMS int64  `json:"durationMs"`
	PositionMS int64  `json:"positionMs"`
}

ResumeState is the last-played track plus the position to resume from.

func LoadResume added in v0.3.0

func LoadResume() *ResumeState

LoadResume reads the saved resume state, or nil if none/invalid.

func (ResumeState) Track added in v0.3.0

func (r ResumeState) Track() deezer.Track

Track reconstructs a deezer.Track from the saved state.

Jump to

Keyboard shortcuts

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