zenplayer
A terminal-based YouTube Music client with album-art now-playing display, bass-reactive glow, and session persistence.
Features
- Search & play YouTube music directly from the terminal
- Album art now-playing — track thumbnails rendered as truecolor half-block art filling the player panel, with a title/artist/progress-bar overlay
- Bass-reactive glow — the overlay background pulses with the music's low-end energy (40–240 Hz FFT)
- Dual-screen layout — player view with search sidebar, toggled via
ctrl+p - Full-screen search — debounced (300ms), cached (5min TTL) async search with configurable result depth
- Search preview — arrow through results to see a thumbnail and word-wrapped description in the sidebar
- mpv-backed playback — seek, volume, pause, next/previous via IPC over Unix socket
- Clickable controls — prev/play/next buttons in the controls bar are mouse-clickable
- Volume persistence — volume changes are saved to the config file
- History — last played tracks stored with playback position; browse, play, remove, or clear entries
- Session persistence — quitting saves the current track + position (−10s); on restart, press
rto resume - Zen mode — minimal, visually dampened full-screen view with just title, artist, and basic controls
- Stall-resistant output — a non-blocking terminal writer with drop detection that self-recovers on slow terminals
- Thumbnail caching — cover art cached on disk for instant replays
Requirements
- Python 3.11+
- mpv — audio playback engine (tested with 0.41.0)
- A truecolor-capable terminal for full-quality album art (falls back gracefully otherwise)
Optional (for bass-reactive glow)
- PulseAudio —
pactlandparecare used to capture live audio for the FFT bass analysis. Without these, the bass-reactive glow is disabled but all other features work.
Install
From PyPI
pip install zenplayer
From source
git clone https://github.com/bjornramberg/zenplayer.git
cd zenplayer
pip install .
Platform-specific mpv install
# macOS
brew install mpv
# Ubuntu / Debian
sudo apt install mpv
# Arch
sudo pacman -S mpv
# Fedora
sudo dnf install mpv
Usage
zenplayer
Or run as a Python module:
python -m zenplayer
The search bar is focused on startup — just start typing to search. Press escape to unfocus it and use keyboard shortcuts.
Keyboard shortcuts
Global (all screens):
| Key | Action |
|---|---|
space |
Play / Pause |
→ / ← |
Seek forward / backward 5s |
shift+→ / shift+← |
Seek forward / backward 30s |
+ / - |
Volume up / down (5% steps) |
shift++ / shift+- |
Volume up / down (15% steps) |
j / k |
Next / Previous track |
f or / |
Focus search input |
h |
Toggle history screen |
r |
Resume last session |
q |
Quit |
escape |
Unfocus search / Close overlays |
Player screen:
| Key | Action |
|---|---|
f1 |
Toggle zen mode |
History screen:
| Key | Action |
|---|---|
enter |
Play selected track (resumes from saved position) |
backspace / delete |
Remove selected entry |
ctrl+u |
Clear all history |
escape |
Close history |
Zen mode
Press f1 to toggle zen mode — a minimal, visually dampened view that hides the search panel, album art, queue, and controls bar. Only the track title, artist, duration, and prev/play/next buttons are shown. Press f1 again to return to the full view.
History
Press h to open the history screen — a full-screen overlay showing all previously played tracks (newest first). Select a track and press enter to play it from where you last left off. History entries show the saved position next to the duration.
Session persistence
When you quit the app (q), the current track and playback position (−10s) are saved. On the next startup, a "Press r to resume where you left off" banner appears. Press r to continue from the saved position.
Configuration
~/.config/zenplayer/config.json:
{
"volume": 50,
"reactive_fps": 24,
"search_limit": 30,
"history_limit": 100
}
| Key | Description | Default |
|---|---|---|
volume |
Initial volume (0–100); updated in-app and persisted | 50 |
reactive_fps |
How often the bass analysis runs and the glow updates | 24 |
search_limit |
How many results each search fetches | 30 |
history_limit |
Max entries stored in play history | 100 |
Data files
| Path | Contents |
|---|---|
~/.config/zenplayer/config.json |
Volume, FPS, limits, last session |
~/.cache/zenplayer/thumbs/ |
Cached YouTube thumbnails |
~/.cache/zenplayer/history.json |
Play history with positions |
~/.cache/zenplayer/search/ |
Cached search results (JSON, 5min TTL) |
Architecture
zenplayer/
├── __init__.py # Package version
├── __main__.py # Entry point: main()
├── app.py # ZenPlayer(App) shell, CSS, keybindings, bass-reactive tick
├── config.py # JSON config at ~/.config/zenplayer/config.json
├── diagnostics.py # Stall sampler + tick/state logging (troubleshooting)
├── nonblocking_output.py # Non-blocking terminal writer w/ drop detection
├── audio/
│ ├── analyzer.py # AudioAnalyzer — FFT + bass-power extraction via numpy
│ ├── capture.py # AudioCapture — parec/arecord subprocess for live audio
│ ├── extractor.py # yt-dlp search + TrackInfo dataclass
│ └── player.py # MpvPlayer — mpv subprocess + Unix socket IPC
├── screens/
│ ├── player_screen.py # Main player layout (album art + search sidebar + controls)
│ ├── search_screen.py # Full-screen search overlay (debounced, 300ms)
│ └── history_screen.py # Full-screen history overlay
├── widgets/
│ ├── _art.py # Shared half-block render helpers (quantize, run-merge)
│ ├── album_art.py # AlbumArt — full-panel truecolor half-block art
│ ├── controls.py # Controls — prev/play/next buttons + volume bar + time
│ ├── now_playing.py # NowPlayingOverlay — title/artist/progress + bass glow
│ ├── queue_view.py # QueueView — horizontal queue display
│ ├── resume_prompt.py # ResumePrompt — "Press r to resume" banner
│ ├── search_preview.py # SearchPreview — square thumbnail + description
│ ├── search_results.py # SearchResults — ListView of SearchResultItems
│ └── zen_now_playing.py # ZenNowPlaying — minimal centered view for zen mode
└── utils/
├── cache.py # Search result disk cache with TTL
├── format.py # Duration formatting helpers
├── history.py # Play history persistence with positions
└── thumbnail.py # Thumbnail fetch + disk cache
How the album art works
- When a track starts,
AlbumArtkicks off a background worker that fetches the YouTube thumbnail (hqdefault.jpg) and caches it at~/.cache/zenplayer/thumbs/ - The image is center-cropped to the player panel's aspect ratio, downscaled to
W×2Hpixels (W×H terminal cells), and quantized to a 128-color palette (no dithering) - Each cell is rendered with the
▀half-block: the top pixel as foreground color and the bottom pixel as background color, giving full 2× vertical resolution. Consecutive cells sharing the same color pair are run-length-merged into a single span, so a 188×78 panel renders ~1.2k spans instead of ~14.7k (about 12× fewer rich styles and ~12× faster repaints) - A
NowPlayingOverlaydocked at the bottom shows the title, artist, and a progress bar; its background glows and tints red in sync with bass energy from a 40–240 Hz FFT band - While a thumbnail loads (or if none is available) a deterministic gradient cover derived from the track id is shown instead; pausing appends "(paused)" to the artist line
License
MIT License
Metadata
Release files for zenplayer 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zenplayer-0.3.3.tar.gz | 36.9 kB | With provenance | Details for zenplayer-0.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zenplayer-0.3.3-py3-none-any.whl | Python 3 | none | any | Details for zenplayer-0.3.3-py3-none-any.whl |
Total release size: 75.2 kB
Release files / zenplayer-0.3.3.tar.gz
| Download URL | zenplayer-0.3.3.tar.gz |
|---|---|
| Size | 36.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3df642c887e66258509e834f88386bd350ac3b24bed51ee9abcd9055b0096162
|
|
BLAKE2b-256 checksum How to use checksums |
7b083081cac3fede217b6c119c775b7042320ed4f5332d1fcee69a3a8d1d1ede
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency logRelease files / zenplayer-0.3.3-py3-none-any.whl
| Download URL | zenplayer-0.3.3-py3-none-any.whl |
|---|---|
| Size | 38.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8df15eb9828cc247b9081d697a030319ad0525104e31ada09eb53df91d1a07d
|
|
BLAKE2b-256 checksum How to use checksums |
706dcda87e4b6fc6ac977cb1bc2c1fa51d2ccfd938ba89a475ef0d66b7ff66ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency logSecurity for zenplayer 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for zenplayer-0.3.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.