spotui
A Spotify terminal client with playback controls, search, playlists and a Now Playing view.
- Go
- Bubble Tea
- OAuth 2.0
- Spotify API
▶ Playing God
Polyphia
Desktop • vol 65% • shuffle • repeat
/ search • h/l panels • j/k move • enter play • space play/pause • n next • N prev • ,/. seek • +/- vol • s shuffle • r repeat • q quit
○ Click the screen or press i to use the keyboard.
Simulated in your browser, following the real app's layout and key bindings. There is no sound.
spotui.go
Responsive over a slow API
Volume, seek, shuffle, and repeat change on screen right away, and the request goes out once the key has been idle for 300ms. Each press gets a sequence number, so only the latest one is sent.
Reconciling with Spotify
Spotify can take a moment to report a change it has already accepted. While a change is pending, the local value wins over the fetched one, until Spotify catches up or five seconds pass. Without that, controls would flicker back to their old value.
// reconcileValue keeps our pending value until Spotify reports the same one
func reconcileValue[T comparable](p *pending, now time.Time, ours T, theirs *T) {
if !p.active(now) {
return
}
if *theirs == ours {
p.confirm() // Spotify caught up
return
}
*theirs = ours // not yet; keep ours
}Login without a secret
Login uses the OAuth authorization code flow with PKCE. A short-lived server on 127.0.0.1 receives the redirect and checks its state value. The refresh token goes in the operating system's credential store, and access tokens are renewed a minute before they expire.
Polling politely
Playback is fetched every five seconds and progress is estimated in between, so the bar moves every second without a request. When Spotify rate-limits a request, the next sync waits for the Retry-After it sent.
One list, many types
Playlists, liked songs, recent plays, and search results share one generic list type that handles loading, errors, the cursor, and scrolling.
architecture
- Key press
- Local state changes
- Debounce (300ms)
- Spotify Web API
- Playback sync (5s)
- Reconcile
highlights
- OAuth login using PKCE, with no client secret
- Login tokens stored in the operating system's keyring
- Debounced input and backoff that honors Spotify's rate limits
- Vim-style keyboard controls
Now Playing
Playing God
Polyphia
Remember That You Will Die
▶ Playing
on Desktop (Computer) • vol 65%
shuffle • repeat