A lightweight, terminal-based Spotify music player written in Golang using Bubble Tea, Lip Gloss, and go-librespot.
The application compiles to the command-line binary rukia-player and starts playing a specified Spotify playlist immediately upon invocation.
Currently, the player supports playlists provided directly through the command line.
Support for browsing playlists from the user's Spotify account, listing available playlists, and navigating between them is planned and included in the project roadmap.
The project is named after Rukia Kuchiki from Bleach. The connection is thematic rather than literal: Rukia is strongly associated with precision, control, deliberate movement, and the named dances of Sode no Shirayuki.
Those ideas map naturally to a music player. Playback is also built around sequence and timing: tracks move forward, pause, resume, repeat, shuffle, and transition while remaining under explicit user control.
| Theme | Rukia / Bleach reference | How it maps to the player |
|---|---|---|
| Rhythm and sequence | Sode no Shirayuki's techniques are expressed as named dances | A playlist is an ordered sequence of tracks, with playback moving through that sequence according to the listener's actions |
| Precision and control | Rukia's techniques rely on deliberate, controlled execution | Playback controls are direct and predictable: play, pause, track selection, shuffle, repeat, and volume |
| Flow between movements | Each dance is a distinct technique within the same fighting style | Individual tracks and playback states remain separate operations while forming one continuous listening session |
| Ice and visual identity | Sode no Shirayuki is an ice-type Zanpakuto | The cyan terminal interface and restrained dark palette give rukia-player a cold, minimal visual identity |
| Restraint over excess | Rukia's style emphasizes technique and composure | rukia-player is intentionally lightweight and focused, providing the essential music-player experience without unnecessary interface complexity |
The name reflects the experience the project aims for: controlled playback, rhythm, precision, and minimal distraction.
The Bleach references are part of the project's identity rather than its
internal vocabulary. Packages remain conventional names such as player,
spotify, auth, and ui, keeping the codebase understandable regardless of
whether someone is familiar with the series.
- Native Terminal Playback: Embeds a Spotify Connect receiver using
go-librespotwith PulseAudio/PipeWire audio output. - Spotify Web API Integration: OAuth 2.0 authorization code flow with PKCE, automatic token refresh, structured error parsing, and GET retries that respect Spotify's rate limits. Playback controls retry only selected transient failures with a bounded budget.
- OAuth Callback Server: Loopback-restricted callback handler with explicit listener shutdown. Existing HTTPS configurations continue to use an ephemeral in-memory TLS certificate.
- Flexible Playlist Arguments: Supports raw playlist IDs, IDs with query parameters, full Spotify URLs (
open.spotify.com), and Spotify URIs. - Cyan TUI Theme: Header stats, track listing (Artist - Album, Title, Duration), bold cyan selection text on a dark blue background, shuffle/repeat badges, and bottom progress bar with transient error notices.
- Exact Playlist Selection: Playing a selected row starts that occurrence, including songs repeated in the same playlist. The playing checkmark stays on the acknowledged occurrence while the cursor moves independently.
- Unplayable Track Handling: Tracks restricted or unavailable in the active account's market are visually dimmed in the track table and automatically bypassed during keyboard navigation.
- MPRIS v2 D-Bus Remote Control: Full MPRIS interface (
org.mpris.MediaPlayer2) supportingplayerctl(play-pause,next,previous,status,metadata,volume), media keys, and desktop environment integration (GNOME, KDE Plasma, Polybar, Waybar). - Exit Confirmation Dialog: Modal dialog (
Ctrl+q,q,Ctrl+c) with<No>and<Yes>confirmation buttons. - Internal Authentication: Uses rukia-player's own OAuth implementation and cached streaming credentials.
- Spotify Premium Account: Required by Spotify for playback control and streaming.
- Spotify Developer Application:
- Register an application at Spotify Developer Dashboard.
- Set Redirect URI to:
http://127.0.0.1:8443/callback(or your configured loopback IP and port). - Select Web API.
Build the binary using make:
git clone https://github.com/chavao/rukia-player.git
cd rukia-player
make check # runs formatting, vet, and race detection
make buildThe compiled executable will be placed in ./bin/rukia-player.
To install globally to your $GOPATH/bin:
make installRun rukia-player with your desired playlist ID or URL:
rukia-player '6UUCMxk575eDTwSWa0qQhB?si=fa799fec9a404660'Or using standard Spotify playlist formats:
# Pure ID
rukia-player 6UUCMxk575eDTwSWa0qQhB
# Web URL
rukia-player https://open.spotify.com/playlist/6UUCMxk575eDTwSWa0qQhB
# Spotify URI
rukia-player spotify:playlist:6UUCMxk575eDTwSWa0qQhBOn first launch, if no Client ID is configured, rukia-player interactively requests:
- Client ID
The Client ID and access and refresh tokens are stored in ~/.config/rukia/player/config.json with restricted permissions (0600). If XDG_CONFIG_HOME is set, the path is $XDG_CONFIG_HOME/rukia/player/config.json. A client secret is not needed for new PKCE logins. Existing configurations with a client secret continue to refresh legacy tokens; the stored secret is removed after a new PKCE login.
When the new file is absent, rukia-player copies its previous ~/.config/rukia/config.json configuration to the new location, preserving tokens, device identity, volume, and playlist settings. The original file is retained; subsequent loads and saves use the new file. The same migration applies under XDG_CONFIG_HOME.
The embedded player authenticates using rukia-player's OAuth access token and reuses only rukia-player's streaming credentials in ~/.cache/rukia/librespot/credentials.json (or $XDG_CACHE_HOME/rukia/librespot/credentials.json). Credentials from other clients are never imported.
Expired sessions are refreshed silently with an eight second timeout. A revoked refresh token prompts for login; rate limits, server failures, and network errors are reported without launching the browser. Token persistence warnings appear in the TUI and as a final reminder after the terminal is restored, so quitting cannot discard a warning waiting for display.
Spotify Connect identity is stored as device_id in the same configuration. On the first launch after upgrading, rukia-player saves the existing device identity derived from the current cache location. Later cache directory changes preserve that identity. An invalid stored identity is reported as a configuration error; restore a valid value or remove the field to migrate from the current cache location again.
Alternatively, credentials can be provided via environment variables:
SPOTIFY_CLIENT_IDSPOTIFY_CLIENT_SECRET(optional, for legacy token refresh)SPOTIFY_REDIRECT_URI(optional, defaults tohttp://127.0.0.1:8443/callback)
Existing configured HTTPS redirect URIs remain supported. Register the exact URI in the Spotify Developer Dashboard. Spotify requires a literal loopback IP for new redirect URI registrations.
Both 127.0.0.1 and ::1 are supported for loopback callbacks, including HTTPS certificate hostnames. localhost redirect URIs are rejected.
| Key | Action |
|---|---|
↑ / k |
Move cursor up in track list |
↓ / j |
Move cursor down in track list |
Enter |
Contextual Play/Pause (toggles current track or plays selected track) |
Space |
Toggle Play / Pause |
n / > |
Skip to next track |
p / < |
Skip to previous track |
+ / = |
Increase volume |
- / _ |
Decrease volume |
s |
Toggle shuffle |
r |
Toggle repeat mode |
Ctrl+q / q / Ctrl+c |
Open exit confirmation dialog |
← / → |
Toggle between <No> and <Yes> in dialog |
Enter (in dialog) |
Confirm selected option |
Esc |
Cancel dialog and return to player |
Shuffle displays [?] until Spotify reports its state. Pressing s before synchronization queues your intent: an odd number of presses toggles the observed state once; an even number leaves it unchanged. Later Spotify shuffle changes are reflected in the badge.
Enter pauses or resumes the playing occurrence when its row is selected; selecting another row starts that exact playlist position. If Spotify reports a repeated song without a confirmed local selection, rukia-player leaves the row checkmark unresolved and continues showing the current song in the bottom bar. Spotify does not report occurrence identity, so external jumps or automatic transitions between identical songs cannot distinguish their rows. Exact selection uses the playlist as loaded; playlist edits made elsewhere require reloading it.
rukia-player implements the standard MPRIS v2 D-Bus specification, allowing complete playback control via CLI tools like playerctl and system media shortcuts or widgets.
You can control playback using playerctl:
# Toggle play/pause
playerctl -p rukia-player play-pause
# Skip to next or previous track
playerctl -p rukia-player next
playerctl -p rukia-player previous
# Check playback status and track metadata
playerctl -p rukia-player status
playerctl -p rukia-player metadata
playerctl -p rukia-player metadata title
playerctl -p rukia-player metadata artist
# Adjust volume (0.0 to 1.0)
playerctl -p rukia-player volume 0.8Note
The MPRIS service registers under org.mpris.MediaPlayer2.rukia-player, with rukia and go-librespot registered as aliases. You can use -p rukia-player, -p rukia, -p go-librespot, or simply omit -p if rukia-player is the primary active player.
cmd/rukia-player/: Application entry point.internal/app/: Application lifecycle orchestration, CLI argument parsing, and error boundaries.internal/auth/: Spotify OAuth 2.0 PKCE flow, callback server, optional in-memory TLS certificate generation, configuration persistence.internal/mpris/: MPRIS v2 D-Bus service implementation forplayerctland desktop environment integration.internal/spotify/: Spotify Web API client, playlist metadata and track pagination, player controls.internal/player/: Embeddedgo-librespotdaemon lifecycle and PulseAudio sink.internal/ui/: Bubble Tea model, Lip Gloss styles, exit modal overlay, and renderers.internal/util/: Time, duration, and progress bar formatting utilities.
Copyright (c) 2026 Diego Chavão.
The rukia-player combined executable, which incorporates go-librespot,
is distributed under the GNU General Public License version 3 only
(GPL-3.0-only). The full license is also provided in
LICENSES/GPL-3.0-only.txt.
The project's original MIT license notice is preserved in
LICENSES/MIT.txt. Separately licensed third-party
components retain their respective copyright and license terms; see
THIRD_PARTY_NOTICES.md.
Redistributors of compiled binaries must also meet applicable GPLv3 obligations, including providing the complete corresponding source code and required third-party license notices. See the GPLv3 for details.