app

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: GPL-3.0 Imports: 32 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package app is Smolify's UI: one state, pure views, and handlers, drawn by Flatte in a terminal, window, or browser. It drives playback through Backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextMenu

func ContextMenu(s *State, target string) []flatte.MenuItem

ContextMenu is the menu for a list in the library or a track in the table.

func Handle

func Handle(s *State, ev flatte.Event, fx flatte.Effects[State])

Handle routes events.

func Init

func Init(s *State, fx flatte.Effects[State])

Init follows the player's events and ticks the position while playing.

func Menus(s *State) []flatte.Menu

Menus is the menu bar; its shortcuts are Smolify's playback keys, in every host (plain keys for a terminal, ⌘ chords too in a window). While the search field has focus, plain keys type: only chords stay shortcuts.

func New

func New(be Backend, img Images, web Web, debug io.Writer) flatte.App[State]

New is the app for backend be, with web for search (nil: neither). debug, when not nil, receives a log of player events, commands, and request failures.

func SettingsPath

func SettingsPath(dir string) string

SettingsPath is where settings live in dir (the player's state dir).

func View

func View(s *State, ctx flatte.RenderContext) flatte.Frame

View draws the sign-in screen until the player is ready, then the library, the selected playlist, and the player bar.

func WindowFonts

func WindowFonts() [][]byte

WindowFonts are the font files a window needs for WindowTheme.

func WindowTheme

func WindowTheme() window.Theme

WindowTheme is Smolify's look in a window: dark, the brand violet for focus and default buttons, a soft white for selected rows.

func Windowed

func Windowed(app flatte.App[State]) flatte.App[State]

Windowed is app as a window app: errors and confirmations become system notifications rather than lines on screen.

func WithCache

func WithCache(app flatte.App[State], dir string) flatte.App[State]

WithCache enables a persistent library cache rooted in dir. The cache is keyed by the signed-in Spotify username/account identifier.

func WithCacheStore

func WithCacheStore(app flatte.App[State], store librarycache.Cache) flatte.App[State]

WithCacheStore installs a host-provided library cache.

func WithSettings

func WithSettings(a flatte.App[State], path string, st Settings) flatte.App[State]

WithSettings preserves the native path-based setup for existing callers.

func WithSettingsStore

func WithSettingsStore(app flatte.App[State], store SettingsStore, st Settings) flatte.App[State]

WithSettingsStore installs host storage and applies the loaded settings.

Types

type Backend

type Backend interface {
	Events() <-chan model.Event
	Status(ctx context.Context) (model.Status, error)
	Playlists(ctx context.Context) ([]model.Playlist, error)
	Play(ctx context.Context, uri, skipTo string) error
	PlayPause(ctx context.Context) error
	Next(ctx context.Context) error
	Prev(ctx context.Context) error
	Seek(ctx context.Context, position time.Duration) error
	SetVolume(ctx context.Context, v int) error
	SetShuffle(ctx context.Context, on bool) error
	SetRepeat(ctx context.Context, r model.Repeat) error
	ContextTracks(ctx context.Context, uri string) (model.Listing, error)
	Queue(ctx context.Context, uri string) error
	SetLiked(ctx context.Context, uris []string, liked bool) error
	Liked(ctx context.Context, uris []string) ([]bool, error)
	// Configure changes how the player plays, restarting its session.
	Configure(ctx context.Context, a model.Audio) error
	SetDeviceName(ctx context.Context, name string) error
	// SignOut forgets the sign-in; the player then reports Pairing.
	SignOut(ctx context.Context) error
	// RecentlyPlayed is the lists username played lately, newest first.
	RecentlyPlayed(ctx context.Context, username string, limit int) ([]model.Played, error)
}

Backend is the playback service as the UI uses it (or a fake in tests). Requests block; the UI calls them off the loop.

type HTTPImages

type HTTPImages struct{ Client *http.Client }

HTTPImages fetches and decodes cover art on native hosts.

func (HTTPImages) Fetch

func (h HTTPImages) Fetch(ctx context.Context, url string) (image.Image, error)

type Images

type Images interface {
	Fetch(ctx context.Context, url string) (image.Image, error)
}

Images fetches cover art.

type Settings

type Settings struct {
	// NotifyErrors posts errors and confirmations as notifications (in a
	// window, which shows them nowhere else).
	NotifyErrors bool `json:"notify_errors"`
	// NotifyTracks posts each new track while Smolify is not in front.
	NotifyTracks bool `json:"notify_tracks"`

	Bitrate   int  `json:"bitrate"` // kbps: 96, 160, or 320
	Normalise bool `json:"normalise"`
	Crossfade int  `json:"crossfade_seconds"`
	Autoplay  bool `json:"autoplay"`
	// AudioBackend is the output driver: model.AudioBackendAuto, or one of
	// model.AudioBackendOptions for this OS.
	AudioBackend string `json:"audio_backend"`

	DeviceName string `json:"device_name"`
	Compact    bool   `json:"compact_rows"`

	// Images is how a terminal shows covers: imagesPictures,
	// imagesHalfBlocks, or imagesOff. A window always shows pictures.
	Images int `json:"terminal_images"`
}

Settings are the user preferences changed on the Settings page. The host persists them through SettingsStore.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings are a first launch's settings.

func LoadSettings

func LoadSettings(path string) (Settings, error)

LoadSettings reads the settings at path, using defaults when no file exists.

func (Settings) Audio

func (st Settings) Audio() model.Audio

Audio is how the settings ask the player to play.

type SettingsStore

type SettingsStore interface {
	Save(Settings) error
}

SettingsStore persists user preferences for the current host.

type State

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

State is the whole UI.

type Web

type Web interface {
	Search(ctx context.Context, q string, limit int) (catalog.Results, error)
}

Web is catalog search as the UI uses it (a provider client, or a fake).

Jump to

Keyboard shortcuts

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