diff --git a/README.md b/README.md index 2f31517..64ab083 100644 --- a/README.md +++ b/README.md @@ -1,139 +1,59 @@

- trill: Spotify in your terminal. Lighter than the tab you'd open to look it up. About 20 MB of RAM, 0% CPU while idle, about 2 ms from key press to frame, about 30 ms from launch to library. + trill: Spotify in your terminal. It plays through Spotify's own player, Soloist. About 17 MB of memory at start, 0% CPU while idle, the library on screen in about 50 ms, one 6.6 MB program.

- Rust 2024 + Latest release Linux, PipeWire or PulseAudio macOS on Apple Silicon Windows x86_64 - Built for CachyOS - Requires Spotify Premium + Rust 2024 + Requires Spotify Premium

- trill playing a song: library with pinned playlists and album art on the left, the track list on the right, the progress bar along the bottom + trill playing Dreams by Fleetwood Mac from the album Rumours: the Library sidebar with Liked Songs, Albums, Artists, For You, Queue, Search and playlists, the album cover drawn in colour blocks under it, the album's songs with their play counts, and the now-playing line with the progress bar.

Get started  ·  Features  ·  + For You  ·  Numbers  ·  Keys  ·  FAQ

-trill is a terminal Spotify client that does one thing and does it cheaply. It plays through **Soloist**, Spotify's own headless player, so audio keeps working on the accounts where librespot gets refused. It browses through librespot's private connection, so no Web API limits apply to your library. One async thread does the UI and the networking. It redraws only when something changes, and it never polls. - -## Features +trill is Spotify for the terminal. Audio comes from **Soloist**, Spotify's own headless player, so it plays on accounts where librespot gets refused. Your library comes through librespot's connection, the same private API the official apps use, so the Web API's limits don't get in the way. It stays out of your way too: a small program that sleeps when there's nothing to do.

- What trill does, by key: L synced lyrics, i album art, e 10-band EQ, s smart shuffle, x crossfade, I private session, f like, save and follow, A playlists, / search, y copy link. Plus media keys, the lock screen, the KDE media widget and your phone through Spotify Connect. + What's different about trill. Plays where librespot can't: audio comes from Soloist, Spotify's own player. Small and quiet: about 17.4 MB of memory, and no CPU or timers while idle. For You, worked out here: suggestions from what you play, ranked on your computer; your play history stays on it. Your whole library: playlists, folders, pins, albums, artists and lyrics, through Spotify's own API, with no Web API limits.

-
-Every feature in a sentence - -- **Your library.** Playlists, Liked Songs, saved albums and followed artists. Pinned playlists and folders sit at the top, like in the official app. -- **Artist pages.** Top tracks, then every album, single and EP, newest first. `P` plays the whole discography. -- **Play counts.** Album pages and an artist's top tracks show each song's all-time plays, the same numbers as the official app. -- **Synced lyrics.** The current line lights up and stays in view, and the screen redraws exactly when the next line starts. -- **Real album art.** It uses kitty, Ghostty, WezTerm, foot, iTerm2 or Konsole graphics when the terminal has them, and colour half-blocks everywhere else. -- **10-band EQ** (Linux) with 11 presets, as a PipeWire filter that only touches trill's audio. On Flat it doesn't run at all. -- **Spotify's own crossfade** and gapless transitions, streaming at 320 kbps. -- **Themes,** including `cover`, which takes its accent colour from the album art that's playing. -- **Smart shuffle.** Like Spotify's: a recommended song (✦) after every three of yours, picked from the list's own Spotify radio. -- **Edit as you listen.** Like and unlike, add to your playlists and remove from them; a ✓ shows which playlists already have the song. Every change is safe against edits made on your phone. -- **Desktop native.** On Linux, MPRIS gives you the KDE media widget, the lock screen, media keys, `playerctl` and KDE Connect. On macOS, the media keys, Control Center and the lock screen control trill. -- **Private session.** `I` starts Spotify's private session for your whole account, the same switch as in the official apps: Friend Activity, your profile, recommendations and Wrapped don't see what you play. It ends by itself after 6 hours. On Linux with Soloist it also hides the song from Discord and anything else watching your Spotify devices. Soloist doesn't support a private session, so trill passes its connection to Spotify through a small local relay that marks it private. The relay uses a local certificate that only works for spotify.com, is readable only by you, and is used only by Soloist. Soloist restarts once (~3 s) the first time you turn private on. Mid-song, the music pauses for about 1.5 s either way, so Discord notices the change. -- **Status at a glance.** The now-playing line ends in ` ⇄ ` shuffle (` ⇄✦ ` smart), ` ↻ ` repeat (` ↻1 ` one song) and ` ⊘ ` private session, lit when on and dim when off. -- **Mouse too.** Click to open, select and seek, double-click to play, and scroll with the wheel. The keyboard still does everything. -- **Remembers you.** Volume, EQ, crossfade, shuffle, repeat, sort order and theme come back on the next start. -
- -## Numbers - -

- Speed, on a log scale: key press to redraw 2 ms; reopening Liked Songs (3,901 songs) 2 ms from disk; launch to library on screen 30 ms; press play to playing 0.2 s; search 0.35 s; first open of Liked Songs 0.45 to 0.7 s. -

-

- Memory (PSS): trill 22 MB, Soloist 54 MB, its crash reporter 8 MB, the EQ 4 MB when on. CPU: trill 0% idle and 0.1 to 0.3% playing, Soloist about 2.5% playing. One 9 MB binary. -

- -
-Every measurement - -Measured on an i9-14900HX laptop, with a network round trip to Spotify of about 150 ms. - -| | | -|---|---| -| Launch to library on screen | ~30 ms (usable after login, ~0.35–0.6 s) | -| Open Liked Songs (3,901 tracks), very first time | ~0.45–0.7 s | -| Open it again, also after a restart | ~2 ms from disk, then refreshed in the background (~0.25 s) | -| Search | ~0.35 s | -| Key press to redraw | ~2 ms | -| Press play to playing | ~0.2 s | -| trill RAM at start (♥ set + cover loaded) | ~14 MB PSS | -| trill RAM, Liked Songs open | ~17 MB PSS | -| trill RAM after a while, private session relay on | ~22 MB PSS | -| trill CPU while idle | 0 | -| trill CPU while playing | ~0.1–0.3% of one core (also with lyrics open) | -| Soloist while playing | ~2.5% of one core, ~48–54 MB (+ ~8–11 MB crash reporter) | -| EQ, when not on Flat | ~1.7% of one core, ~4 MB | -| The binary | ~9 MB, nothing else to install besides Soloist | -
- -
-Why it's light - -- One async thread runs the UI and networking. librespot's player runtime is capped to one worker thread instead of one per CPU core. -- Terminal input sits on one blocking thread, so it uses no CPU while idle. -- The screen redraws only on input, player events, or once a second while playing. Nothing polls Spotify. -- Audio is decoded in-process and sent to PipeWire over the PulseAudio protocol. There's no rodio or cpal layer. -- Stream buffers go to `~/.cache/trill/tmp`, not `/tmp`. On CachyOS `/tmp` is tmpfs, which means RAM. -- Track info is fetched 300 tracks per request, with up to 16 requests in parallel, instead of one request per song. -- Each frame builds only the table rows that fit on screen. -- The playlist list is cached, so the sidebar fills on the first frame and refreshes in the background. -- Every list you open is saved to `~/.cache/trill/lists`, so it opens instantly next time, even after a restart. A fresh copy loads in the background and replaces it only if something changed, keeping your place. That refresh, and `R`, only fetch details for songs added since. -- Spotify login and Soloist startup run at the same time. With a saved login, the library is drawn from cache before the login finishes, and keys you type meanwhile wait their turn. -- Freed heap goes back to the OS after big lists load (`malloc_trim`), and glibc is limited to 2 malloc arenas. -- Album art is decoded and resized once per song, off the UI thread. The next song's cover is downloaded while the current one ends, so it changes with the song. -
- -## How it works +## Get started

- How it works: trill runs its UI and networking on one async thread. It browses Spotify through a librespot session with no Web API limits, drives Soloist, Spotify's own player, over a local WebSocket, and talks to your desktop over MPRIS. Soloist streams from Spotify and plays through PipeWire, with the EQ filter when it's on. + Get started in four steps, about ten minutes, once. 1: install trill with one command. 2: get a free Soloist API key from Spotify's developer dashboard and save it. 3: run trill --update-soloist to download Spotify's player. 4: run trill --pair once with your phone, then just trill.

-trill holds two connections to Spotify. Your library, search, lyrics and edits go through librespot's private connection, the same one Spotify's apps use, so the public Web API's rate limits don't apply. Audio comes from **Soloist**, Spotify's own headless player, which trill starts in the background and drives over a local WebSocket. Everything else (queue, shuffle, repeat, the screen) is trill, on a single async thread. - -### Why Soloist - -Since late 2025, Spotify has been refusing audio keys to librespot on more and more accounts ([librespot#1649](https://github.com/librespot-org/librespot/issues/1649)). On those accounts, login and browsing work, but every track fails with `error audio key 0 1` and is skipped. Soloist is Spotify's own player, so it isn't affected. trill starts it in the background, controls it over its local WebSocket, and manages shuffle, repeat and the queue itself. - -trill uses Soloist automatically once the key and Soloist are both in place, and librespot otherwise. To force one, set `backend = soloist` or `backend = librespot` in the [config](#details). - -> [!NOTE] -> Soloist only accepts the API key as a command-line argument. While it runs, anything that can list processes on this machine (`/proc//cmdline`) can see the key. That's fine on a single-user desktop, but keep it in mind on a shared machine. - -
-How song transitions work +You need **Spotify Premium**. Each step happens once. -When a song ends, Soloist would normally play its own autoplay "radio" pick. To prevent that, trill puts your next song into Soloist's queue about 8 s before the end, so the switch is native and gapless. Soloist's queue can't be edited. If you pick a different song during those last 8 s, the queued song is skipped first, and you may hear a split second of it (about 0.15 s). -
+**1. Install trill** -## Get started +**Linux** (x86_64; needs `libpulse`, which comes with PipeWire and PulseAudio): -

- Get started in six steps, about ten minutes, once: install, get a Soloist key, save it, run trill --update-soloist, run trill --pair, then run trill. -

+```bash +mkdir -p ~/.local/bin && curl -fsSL https://github.com/junaydirfan/trill/releases/latest/download/trill-linux-x86_64.tar.gz | tar -xz -C ~/.local/bin +``` -You need **Spotify Premium** and about 10 minutes. Each step only happens once. +**macOS** (Apple Silicon), then open a new Terminal window: -### 1. Install trill +```bash +mkdir -p ~/.local/bin && curl -fsSL https://github.com/junaydirfan/trill/releases/latest/download/trill-macos-arm64.tar.gz | tar -xz -C ~/.local/bin +echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc +``` -**Windows:** paste this into PowerShell. It puts `trill.exe` in `~\.local\bin` and adds that folder to your `PATH`: +**Windows** (PowerShell), then close PowerShell and open a new window: ```powershell $dir = "$HOME\.local\bin"; New-Item -ItemType Directory -Force $dir | Out-Null @@ -142,128 +62,164 @@ Expand-Archive -Force "$env:TEMP\trill.zip" $dir [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "User") + ";$dir", "User") ``` -Then **close PowerShell and open a new window**. Only new windows know where `trill` is; the old one says "trill is not recognized". Use Windows Terminal if you can: it shows real album art, and the old console draws it with coloured blocks. +**2. Get a Soloist key.** Sign in at https://developer.spotify.com/dashboard with your Premium account, open the **Soloist API Key** page and create a key (it starts with `spak_`). It belongs to your account, so keep it private like a password. -**macOS (Apple Silicon):** paste this into Terminal, then open a new Terminal window: +**3. Save it where trill looks for it**, then download Soloist: ```bash -mkdir -p ~/.local/bin && curl -fsSL https://github.com/junaydirfan/trill/releases/latest/download/trill-macos-arm64.tar.gz | tar -xz -C ~/.local/bin -echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc +mkdir -p ~/.config/trill && touch ~/.config/trill/soloist_api_key && chmod 600 ~/.config/trill/soloist_api_key +${EDITOR:-nano} ~/.config/trill/soloist_api_key # paste the key, save +trill --update-soloist ``` -> [!NOTE] -> Album art looks pixelated in Apple's Terminal. That's a known limit of Terminal, not trill: it can't display images, so trill draws the cover with coloured blocks. For the real cover, run trill in [Ghostty](https://ghostty.org) or [iTerm2](https://iterm2.com) (both free). trill picks them up by itself. +On Windows: `New-Item -Force -ItemType File $HOME\.config\trill\soloist_api_key; notepad $HOME\.config\trill\soloist_api_key`, paste, save, then `trill --update-soloist`. -**Linux (x86_64):** download it, or build it (below). It needs `libpulse`, which comes with PipeWire and PulseAudio: +**4. Pair and play.** Run `trill --pair`, open Spotify on your phone (same Wi-Fi), tap the devices icon and pick **trill**. Then run **`trill`**. Your browser opens once to log in; after that it starts straight away. Press `?` for every key. -```bash -mkdir -p ~/.local/bin && curl -fsSL https://github.com/junaydirfan/trill/releases/latest/download/trill-linux-x86_64.tar.gz | tar -xz -C ~/.local/bin -``` +**Updating:** `trill --update` gets the latest release; your login, key, pairing and settings stay. trill also mentions a new release at the bottom right, once a day at most. Spotify's Soloist builds last 90 days: when trill says yours has expired, run `trill --update-soloist` again. + +
+If something doesn't work + +- **"trill is not recognized" / "command not found":** open a new terminal window after installing. On Linux with fish, run `fish_add_path ~/.local/bin` once. +- **Every song is skipped with "Unavailable":** trill isn't playing through Soloist, and the message says what's missing. Usually the key isn't in `~/.config/trill/soloist_api_key` (on Windows, `C:\Users\\.config\trill\soloist_api_key`; a key saved as `soloist_api_key.txt` works too), or `trill --update-soloist` hasn't been run. +- **"Soloist isn't signed in":** run `trill --pair` again with your phone on the same Wi-Fi, and allow the firewall or local network prompt on Windows and macOS. +- **"Can't reach Spotify":** trill is offline. Your saved login is kept, so just start it again once you're connected. +- **Album art looks pixelated:** the terminal can't show images, so trill draws the cover with coloured blocks. That's always the case in Apple's Terminal, Alacritty, tmux and the old Windows console. Ghostty, kitty, WezTerm, foot, iTerm2, Konsole and Windows Terminal show the real cover. +- **`trill --update` can't replace the file** (say a package manager installed it): quit trill and run the install command from step 1 again. On Windows the file is locked while trill runs. +- **Anything else:** run `TRILL_LOG=debug trill` (Windows: `$env:TRILL_LOG="debug"; trill`). trill's log is then `~/.cache/trill/trill.log`, Soloist's is `~/.cache/trill/soloist.log`. An issue with the log helps. + +Setting trill up on a second computer? Copy only `~/.config/trill/soloist_api_key` and pair there. Don't copy `~/.local/share/trill/soloist-data`: it's this computer's Soloist identity, and two players sharing one keep taking playback from each other. +
-Build from source instead +Build from source -You only need Rust for this; "`cargo` is not recognized" means it isn't installed, and the downloads above don't need it. +You only need Rust for this; the downloads above don't. - **Linux:** needs `rust`, `libpulse`, `openssl` and `pkgconf` (all already on CachyOS). ```bash git clone https://github.com/junaydirfan/trill && cd trill cargo build --release install -Dm755 target/release/trill ~/.local/bin/trill + install -Dm644 assets/trill.desktop ~/.local/share/applications/trill.desktop # optional: name and icon in KDE's media widget ``` - Optional: install the launcher so KDE shows trill's name and icon in the media widget (it also adds a menu entry). With the `spotify-launcher` package installed, you can set its `Icon=` to `spotify-launcher` for Spotify's icon. - ```bash - install -Dm644 assets/trill.desktop ~/.local/share/applications/trill.desktop - ``` -- **macOS:** run `xcode-select --install`, install Rust from https://rustup.rs, then `cargo install --git https://github.com/junaydirfan/trill`. -- **Windows:** install Rust from https://rustup.rs (its installer offers to set up the Visual Studio C++ build tools it needs), open a new window, then `cargo install --git https://github.com/junaydirfan/trill`. +- **macOS:** `xcode-select --install`, Rust from https://rustup.rs, then `cargo install --git https://github.com/junaydirfan/trill`. +- **Windows:** Rust from https://rustup.rs (its installer sets up the C++ build tools), a new window, then `cargo install --git https://github.com/junaydirfan/trill`. -`cargo install` puts `trill` in `~/.cargo/bin`, which the Rust installer adds to your `PATH`. +To update a build: `cargo install --git https://github.com/junaydirfan/trill --force`, or `git pull` and build again.
-### 2. Get your Soloist API key - -trill plays music through **Soloist**, Spotify's own player ([why](#why-soloist)). Soloist needs a free API key that belongs to your Spotify account: - -1. Sign in at https://developer.spotify.com/dashboard with your Premium account. The first time, accept the developer terms. -2. Open the **Soloist API Key** page and create a key. It starts with `spak_`. - -Everyone needs their own key, made with their own Premium account: a friend can't use yours. Keep it private, like a password. Spotify's guide: [Soloist authentication](https://developer.spotify.com/documentation/soloist/concepts/authentication). - -### 3. Save the key where trill looks for it - -**Windows (PowerShell):** this opens an empty file in Notepad. Paste the key, press Ctrl+S, and close Notepad. - -```powershell -New-Item -Force -ItemType File $HOME\.config\trill\soloist_api_key | Out-Null -notepad $HOME\.config\trill\soloist_api_key -``` - -**macOS and Linux:** this makes a file only you can read and opens it. Paste the key and save (in nano: Ctrl+O, Enter, Ctrl+X). - -```bash -mkdir -p ~/.config/trill && touch ~/.config/trill/soloist_api_key && chmod 600 ~/.config/trill/soloist_api_key -${EDITOR:-nano} ~/.config/trill/soloist_api_key -``` - -### 4. Download Soloist +## Features -```bash -trill --update-soloist -``` +

+ What trill does, by key: / search; For You, picks from what you play; s smart shuffle; L synced lyrics; i album art; e 10-band EQ; x crossfade; z sleep timer; F find in a list; f like, save and follow, A adds to playlists; I private session; media keys. Plus pins and folders, artist pages with play counts, themes and the mouse. +

-This fetches Spotify's Soloist build for your system. Spotify's builds expire after 90 days; when trill says yours has, run this again. +
+Every feature in a line + +- **Your library:** playlists, folders, Liked Songs, saved albums and followed artists, with your pins at the top like in the official app. +- **Artist pages:** top songs, then every album, single and EP, newest first. Albums and top songs show their all-time play counts. `P` plays the whole discography. +- **For You:** songs picked from what you play, worked out on your computer. See [For You](#for-you). +- **Smart shuffle** (`s` twice): a song Spotify recommends (✦) after every three of yours. +- **Synced lyrics** (`L`): the line being sung lights up and stays in view. +- **Album art** (`i`): real images where the terminal can, colour blocks elsewhere. +- **10-band EQ** (`e`, `E`, Linux): 11 presets, as a PipeWire filter only trill's audio goes through. On Flat it doesn't run at all. +- **Crossfade** (`x`): Spotify's own, gapless, streaming at 320 kbps. +- **Sleep timer** (`z`): 15 to 90 minutes or the end of the song. The volume fades out over 8 s, then it pauses. +- **Find in a list** (`F`): narrows the open list as you type, by title, artist or album. +- **Sort** (`o`): newest first, playlist order, title, artist, album or length. Each list remembers its own. +- **Search** (`/`): songs, albums, artists and playlists; `↑` brings back past searches. +- **Edit as you listen:** like, save and follow (`f`), add to and remove from playlists (`A`, ✓ shows where it already is), remove from the open playlist (`D D`). Safe against edits made on your phone meanwhile. +- **Queue** (`a`, `c`): songs you add play next; `D D` in the queue takes one out. +- **Private session** (`I`): Spotify's own, for your whole account. On Linux it also hides the song from Discord. +- **Desktop:** MPRIS on Linux (KDE's media widget, the lock screen, media keys, `playerctl`, KDE Connect), Now Playing on macOS, and your phone through Spotify Connect. +- **Themes** (`t`), including `cover`, which takes its colour from the album art. **The mouse** works too. +- **Remembers you:** volume, EQ, crossfade, shuffle, repeat, sorts, theme and searches come back next time. +
-### 5. Pair with your phone +## For You -```bash -trill --pair -``` +

+ trill's For You: fifty songs picked from what you play, each with a Why column saying where it came from, such as the radio of a song you play or an artist like one you play. +

-Open Spotify on your phone (on the same Wi-Fi), tap the devices icon and pick **trill**. On Windows or a Mac, allow it when you're asked about the firewall, incoming connections or local network access, or your phone won't see it. +

+ How For You works. 1: what you play: every song played for 30 seconds, logged on your computer, older plays counting less. 2: your seeds: your top songs and top artists. 3: Spotify's radio of those songs and the artists related to yours, fetched at once and kept for 12 hours. 4: ranked here: liked songs left out, songs you play a lot pushed down, no one artist takes over, and X hides a song for good. Your play history stays on your computer. +

-### 6. Play +**✦ For You** in the sidebar is 50 songs picked from what you actually play. The Why column says where each one came from. Press `X` on one you don't want and it won't come back (that works on ✦ smart-shuffle songs too). It opens at once from last time and is worked out again after 12 hours, or when you press `R`. Until you've played 15 different songs, your newest liked songs help it along. -```bash -trill -``` +
+How it ranks, and what goes to Spotify -Your browser opens once to log in to Spotify, which trill uses to browse your library. Later starts skip it (`trill --logout` forgets the login). Press `?` for every key. +- **What you play:** every song played for 30 s goes in `~/.local/share/trill/plays`. A play counts half as much every 14 days. +- **Seeds:** your 4 top songs, and the 4 artists of your top songs. +- **Candidates:** the radio of each seed song (what smart shuffle uses), and the top songs of the 12 artists Spotify most often lists as related to yours. +- **Ranking, on your computer:** songs from several sources add up. Liked songs and songs you said no to (`~/.local/share/trill/not_interested`) are left out. A song you played *n* times in the last 30 days counts 1/(1+*n*). Each further song by the same artist counts half (3 at most), and each further one from the same source 0.8, so the list stays varied. +- **What goes to Spotify,** over the same connection trill uses for browsing: the ids of your 4 seed songs (their radio), up to 40 of your top songs (to look up their artists), up to 16 artist ids (their pages) and the songs suggested (for titles and covers). About 20 requests, at most every 12 hours unless you press `R`. Your play log and your no's stay on your computer. +
-### Updating +## Numbers -```bash -trill --update -``` +

+ Footprint, measured on an i9-14900HX, memory as PSS. trill at start: 17.4 MB; playing from Liked Songs, 3,953 songs: 20.6 MB; with For You open: 20.2 MB; Soloist, Spotify's player, while playing: about 49 MB. CPU: 0% idle and paused, about 0.2% playing. The library on screen about 50 ms after launch; For You worked out in about 1.5 s and reopened in 7 ms. +

-That downloads the latest release and puts it in place of your trill; restart trill afterwards. Your login, key, pairing and settings stay. Once a day trill also checks for a new release and says so at the bottom right. `trill --version` shows what you have, and the [releases page](https://github.com/junaydirfan/trill/releases) what's new. +
+Every measurement -On v0.2.0 or older (no `--update` yet), or if it can't replace the file (say a package manager installed trill), run the download again. Quit trill first; on Windows the file is locked while it runs. +Measured on the v0.6.0 release download on an i9-14900HX laptop (CachyOS), with the Soloist backend, a library of 3,953 liked songs and 110 playlists, and a network round trip to Spotify of about 150 ms. trill ran in tmux at 140×42 on a copy of a real config and cache. Memory is PSS from `/proc//smaps_rollup`; wakeups are voluntary context switches over all of trill's threads. -**Windows** (PowerShell): +| | | +|---|---| +| Launch to library on screen | ~50 ms (from disk; usable after login, ~0.45–0.55 s) | +| trill at start | 17.4 MB (peak 26 MB) | +| Liked Songs open and playing | 20.6 MB | +| After a few song changes | 19.9 MB (peak 30 MB) | +| For You open | 20.2 MB | +| CPU idle, and paused | 0 | +| Wakeups idle | ~3 a minute: Spotify's keepalive ping and its reply; paused, the same | +| CPU playing | ~0.2% of one core | +| Key press to frame | ~2.6 ms moving in 3,953 songs; ~5.6 ms re-sorting them; ~4.4 ms per key in find (timed inside trill with a timing build of this code) | +| For You, worked out | ~1.4–2.2 s; reopened from disk, 7 ms | +| Soloist while playing | ~49 MB, plus ~11 MB for its crash reporter; ~2% of one core | +| EQ, when not on Flat | ~4 MB, ~1.7% of one core (not re-measured for v0.6.0) | +| The program | 6.6 MB, nothing to install besides Soloist | + +The release download links OpenSSL 3. On CachyOS and Arch that's a compatibility library nothing else uses, so about 1.3 MB of its memory counts against trill alone; built from source there, trill uses the system's OpenSSL and starts at about 15.8 MB. +
-```powershell -Invoke-WebRequest https://github.com/junaydirfan/trill/releases/latest/download/trill-windows-x86_64.zip -OutFile "$env:TEMP\trill.zip" -Expand-Archive -Force "$env:TEMP\trill.zip" "$HOME\.local\bin" -``` +
+Why it's light -**macOS:** +- One async thread does the screen and the networking; keys are read on a thread of their own that sleeps until you type. +- The screen redraws only when something changes: a key, a player event, or once a second while playing. Lyrics redraw exactly when the next line starts. +- Nothing runs on a timer while idle. A dropped connection is noticed on your next key, not by polling. +- Every list you open is saved in `~/.cache/trill/lists`, so it opens at once, also after a restart, and a fresh copy loads in the background. Refreshing only fetches details for songs added since. +- Song details come 300 to a request, up to 16 requests at once. A request that fails leaves the saved list alone instead of shortening it. +- The first frame comes from disk while the login runs. A terminal that doesn't answer the image query (tmux, for one) is remembered, so later starts don't wait for it. +- On Linux, freed memory goes back to the system after big lists load and after each cover is decoded. +- Each frame builds only the rows that fit on screen. +
-```bash -curl -fsSL https://github.com/junaydirfan/trill/releases/latest/download/trill-macos-arm64.tar.gz | tar -xz -C ~/.local/bin -``` +## How it works -**Linux:** +

+ How it works. trill runs its screen and networking on one async thread, with keys read on a thread of their own. It browses your library through librespot's session, the same private API the official apps use, and keeps your lists on disk so they open at once. It drives Soloist, Spotify's own headless player, over a local WebSocket; Soloist streams from Spotify and plays through PipeWire, with the EQ when it's on. The desktop gets MPRIS on Linux and Now Playing on macOS. +

-```bash -curl -fsSL https://github.com/junaydirfan/trill/releases/latest/download/trill-linux-x86_64.tar.gz | tar -xz -C ~/.local/bin -``` +**Why Soloist:** since late 2025, Spotify has been refusing audio keys to librespot on more and more accounts ([librespot#1649](https://github.com/librespot-org/librespot/issues/1649)): login and browsing work, but every song fails and is skipped. Soloist is Spotify's own player, so it isn't affected. trill starts it in the background, drives it over its local WebSocket, and keeps the queue, shuffle and repeat itself. With no Soloist key, trill plays through librespot instead; `backend = soloist` or `backend = librespot` in the config picks one. -Built it yourself? Run `cargo install --git https://github.com/junaydirfan/trill --force`, or `git pull` and build again in your clone. +> [!NOTE] +> Soloist only takes its API key on the command line, so while it runs, anything that can list processes on this computer can see the key. Fine on your own desktop; keep it in mind on a shared machine. -Soloist updates separately: when trill says your Soloist build has expired (Spotify's builds last 90 days), run `trill --update-soloist`. +
+How songs change over -Stuck? See [Troubleshooting](#troubleshooting). +When a song ends, Soloist would play its own autoplay pick. To prevent that, trill puts your next song in Soloist's queue about 8 s before the end, so the change is gapless. Soloist's queue can't be edited, so if you pick another song in those last 8 s, the queued one is skipped first and you may hear a split second of it. +
## Keys @@ -272,28 +228,29 @@ Stuck? See [Troubleshooting](#troubleshooting).

-Keys as text +Keys as text, and the mouse | key | action | | key | action | |---|---|---|---|---| | `↑↓` `jk` `PgUp/PgDn` `g/G` | move | | `f` | like a song · save an album · follow an artist | | `Tab` `h` `l` | switch pane | | `A` | add to or remove from a playlist (✓ = already in it) | -| `Enter` | play / open | | `D` `D` | remove from the open playlist | -| `Esc` `Backspace` | back | | `L` | lyrics | -| `Space` | play / pause | | `i` | album art on / off | -| `n` / `p` | next / previous | | `t` | next colour theme | -| `w` | jump to the playing song | | `s` | shuffle ⇄: off → on → smart ⇄✦ | -| `←→` or `,` `.` | seek ±10 s | | `r` | repeat ↻: off → all → one ↻1 | -| `+` / `-` | volume ±5% | | `o` / `O` | next / previous sort order | -| `a` | add to queue | | `e` / `E` | next EQ preset / EQ panel | -| `c` | show the queue | | `x` | crossfade off / 3 / 5 / 8 / 12 s | -| `/` | search | | `R` | reload the current list | -| `P` | play everything in the list | | `?` | key help | -| `y` | copy the Spotify link of the highlighted song, album, playlist or artist | | `Y` | copy the link of the open list | -| `I` | private session ⊘ on / off | | `u` / `U` | open the song's album / artist | +| `Enter` | play / open | | `D` `D` | remove from the open playlist, or from the queue | +| `Esc` `Backspace` | back (clears a find first) | | `X` | not interested (For You, ✦ songs) | +| `Space` | play / pause | | `s` | shuffle ⇄: off → on → smart ⇄✦ | +| `n` / `p` | next / previous | | `r` | repeat ↻: off → all → one ↻1 | +| `←→` or `,` `.` | seek ±10 s | | `x` | crossfade off / 3 / 5 / 8 / 12 s | +| `+` / `-` | volume ±5% | | `z` | sleep timer: 15 / 30 / 45 / 60 / 90 min, end of song, off | +| `a` | add to queue | | `/` | search (`↑↓` past searches) | +| `c` | show the queue | | `F` | find in this list | +| `w` | jump to the playing song | | `o` / `O` | sort this list: next / previous order | +| `P` | play everything in the list | | `u` / `U` | open the song's album / artist | +| `L` | lyrics | | `R` | reload the list (For You: new picks) | +| `i` | album art on / off | | `e` / `E` | next EQ preset / EQ panel | +| `t` | next colour theme | | `I` | private session ⊘ on / off | +| `y` / `Y` | copy the link of the highlighted item / the open list | | `?` | every key | | `q` `Ctrl-C` | quit (pauses first, so Spotify and Discord stop showing the song) | | | | -**Mouse:** click a sidebar entry to open it, click a song to select it, double-click to play it, click the progress bar to seek, and use the wheel to scroll the pane under the pointer. Click ⇄, ↻ or ⊘ to toggle shuffle, repeat or private session. In the add-to-playlist picker, click a playlist to highlight it and double-click to add or remove the song. In the EQ panel, click a band to pick it. A click outside either one closes it. To select text in the terminal, hold `Shift` while dragging (`Option` in iTerm2, `Fn` in macOS Terminal), or set `mouse = off` in the config. +**Mouse:** click a sidebar entry to open it, a song to select it, double-click to play, click the progress bar to seek, and scroll the pane under the pointer. Click ⇄, ↻ or ⊘ to toggle them. In the playlist picker and the EQ panel, click to pick; a click outside closes them. To select text, hold `Shift` while dragging (`Option` in iTerm2, `Fn` in Apple's Terminal), or set `mouse = off`.
## Details @@ -301,131 +258,119 @@ Stuck? See [Troubleshooting](#troubleshooting).
Library, sorting and pins -- **Sorting:** playlists and Liked Songs show **most recently added first**, with an **Added** column, so playing from the top plays your newest additions first. `o` steps through the other orders: the playlist's own order, title, artist, album and length (`O` steps back). The list's header shows the current order, and it's remembered. Artist pages and albums always keep Spotify's order. -- **Pins:** playlists and folders you pinned in Spotify sit at the top of the library, in the same order as the official app. Opening a pinned folder lists its playlists. trill can't pin or unpin, because Spotify ignores pin changes from third-party clients, so pin them from the official app. -- **Albums and Artists:** the two entries under Liked Songs list your saved albums and the artists you follow, most recent first, and sort like playlists. Opening an artist shows their top tracks, then their albums, singles, EPs and compilations, newest first. -- **Liking, saving, following:** `f` likes or unlikes the highlighted song, saves or unsaves the highlighted album, and follows or unfollows the highlighted artist. With nothing highlighted, it likes the song playing. Everything in your library shows a ♥, including the now-playing line. The ♥ changes straight away and changes back if Spotify refuses. -- **Smart shuffle:** `s` steps through off, shuffle and smart shuffle. Smart shuffle plays your list shuffled with a song Spotify recommends after every three, marked ✦ in the now-playing line and the queue (`c`). They come from the list's Spotify radio (playlists, albums, artists), or the playing song's radio for Liked Songs and search results. Like in Spotify, they're only played, not added. To keep one, press `w`: it shows the recommendation at the top of the queue, where `f` likes it and `A` adds it (the picker starts on the playlist it was picked for, so `w` `A` `Enter` adds it there). -- **Album and artist of a song:** `u` opens the album of the highlighted song (or the one playing), `U` its artist (the first one, for songs with several). `Esc` comes back. -- **Jump to the playing song:** `w` opens the list it's playing from and highlights it. A song that isn't in that list (a smart-shuffle recommendation, or one started from your phone) is shown at the top of the queue instead, where `f` likes it and `A` adds it. -- **Play all:** `P` plays every track in the open list, opening the albums and playlists in it. On an artist page that's the whole discography, top tracks first, without repeats (about 1 s for ~100 songs). -- **Playlists:** `A` opens a picker of the playlists you can edit, which are yours and collaborative ones. A ✓ marks the ones that already have the song. `Enter` adds it, or removes it from a ✓ playlist, and the picker stays open for more until `Esc`. In one of your playlists, pressing `D` twice removes the highlighted song. trill re-reads the playlist from Spotify first, so an edit made on your phone in the meantime can't make it remove the wrong song. - -These actions go through the same private Spotify API as the rest of trill (not the Web API), so no rate limits apply. Each one takes about 0.4–0.5 s to reach Spotify. +- **Sorting:** playlists and Liked Songs start **newest first**, with an Added column. `o` steps through the playlist's own order, title, artist, album and length (`O` steps back), and each list remembers its own. Albums and artist pages keep Spotify's order. +- **Find** (`F`): type to narrow the open list; `↑↓` move in it, `Enter` keeps it, `Esc` clears it. Playing from a narrowed list plays what's shown. +- **Pins:** playlists and folders you pinned in Spotify sit at the top, in the official app's order. trill can't pin or unpin (Spotify ignores pin changes from other clients), so pin them in the official app. +- **Smart shuffle:** `s` steps through off, shuffle and smart shuffle. Recommendations (✦) come from the list's Spotify radio, or the playing song's for Liked Songs and search. To keep one, press `w`: it shows at the top of the queue, where `f` likes it and `A` adds it (the picker starts on the list it was picked for). `X` says no to it. +- **Album and artist of a song:** `u` / `U` open them for the highlighted song, or the one playing. +- **Play all:** `P` plays every song in the open list, opening the albums and playlists in it. On an artist page that's the whole discography. +- **Playlists:** `A` opens a picker of the playlists you can edit (yours and collaborative ones). `Enter` adds the song, or removes it from a ✓ playlist, and the picker stays open until `Esc`. trill re-reads a playlist before removing, so an edit made on your phone meanwhile can't make it remove the wrong song. + +These go through the same private API as the rest of trill, so no rate limits apply; each takes about 0.4–0.5 s to reach Spotify.
-Lyrics and album art +Lyrics, album art, EQ, crossfade and themes -- **Lyrics:** `L` swaps the track list for the current song's lyrics. When Spotify has timed lyrics, the current line is highlighted and kept in view. Otherwise, `j`/`k` scroll. Lyrics are only fetched while this view is open. -- **Album art:** the cover sits under the playlist list when the window is tall enough. Terminals with an image protocol show a real image. kitty, Ghostty, WezTerm, foot and iTerm2 are detected automatically, and Konsole uses the iTerm2 protocol. Everywhere else, including Alacritty, tmux and VS Code, the cover is drawn with coloured half-block characters. For a sharp image in VS Code, turn on `terminal.integrated.enableImages`. -
+- **Lyrics:** `L` swaps the list for the song's lyrics. With timed lyrics the current line is highlighted; otherwise `j`/`k` scroll. They're only fetched while this view is open. +- **Album art:** the cover sits under the sidebar when there's room. kitty, Ghostty, WezTerm, foot and iTerm2 are detected, and Konsole uses the iTerm2 protocol. Elsewhere, including Alacritty, tmux and VS Code (unless `terminal.integrated.enableImages` is on), it's coloured half-blocks. +- **EQ** (Linux): `e` cycles Flat, Bass Boost, Bass Reducer, Treble Boost, Vocal, Rock, Pop, Hip-Hop, Electronic, Acoustic, Loudness and Custom. `E` opens the 10-band panel (32 Hz–16 kHz, ±12 dB; `↑↓` band, `←→` adjust, `0` reset). It's a small PipeWire filter only trill's audio goes through. On Flat it doesn't run; the first other setting starts it and restarts the player once (~3 s, resuming where you were). `eq = off` disables it. +- **Crossfade:** `x` cycles off, 3, 5, 8 and 12 s. It's Soloist's own; applying it restarts Soloist once (~3 s, resuming). +- **Quality:** trill sets Soloist to 320 kbps (it defaults to 160). +- **Themes:** `t` cycles spotify, ocean, violet, sunset, rose, mono and cover. `cover` takes its colour from the album art, made readable on a dark terminal. -
-EQ, crossfade, quality and themes - -- **EQ:** `e` cycles through the presets: Flat, Bass Boost, Bass Reducer, Treble Boost, Vocal, Rock, Pop, Hip-Hop, Electronic, Acoustic, Loudness and Custom. `E` opens the 10-band panel (32 Hz to 16 kHz, ±12 dB). In the panel, `↑↓` picks a band, `←→` adjusts it and `0` resets it. A preamp is set automatically so boosts don't clip. - - The EQ is a small PipeWire filter that only trill's audio passes through, so other apps aren't affected. - - **On Flat it doesn't run at all.** The first non-flat setting starts it and briefly restarts the player (~3 s, then it resumes where you were). After that, changes apply live. Set `eq = off` in the config to disable it completely. -- **Crossfade:** `x` cycles through off, 3, 5, 8 and 12 s. This is Spotify's own crossfade inside Soloist. Applying it restarts Soloist (~3 s, then it resumes where you were). -- **Quality:** trill sets Soloist to 320 kbps. Out of the box, Soloist streams at 160 kbps. -- **Themes:** `t` cycles through spotify, ocean, violet, sunset, rose, mono and cover. `cover` takes the accent colour from the album art of the song that's playing: - - Every pixel votes for its colour, weighted by how colourful it is, so a vivid title or detail wins over a large muted area. - - Pastel and off-white covers keep their tint, and black-and-white covers get a light grey. - - The colour is brightened until it reads on a dark terminal. The last colour is remembered, so the next start opens in it. - - The colour comes from the cover trill already decodes for the art (~0.5–1 ms per song). With the art hidden, trill fetches the cover just for its colour (~50–100 KB per song). - - `trill --debug-tint ` prints the colour picked for each result's cover. - -All of these, plus shuffle, repeat, sort order and album art on or off, are saved in `~/.local/share/trill/audio_settings`. Volume is saved too, including changes made from KDE's media controls or your phone. +These and the rest of your keyboard settings are saved in `~/.local/share/trill/audio_settings`.
Config -The config is optional. It lives in `~/.config/trill/config`: +Optional, in `~/.config/trill/config`: ```ini bitrate = 320 # 96 | 160 | 320 -audio_cache_mb = 0 # >0 keeps played tracks on disk (saves bandwidth on repeats) +audio_cache_mb = 0 # >0 keeps played songs on disk (librespot backend) normalise = false -client_id = # your own Spotify app, used ONLY for search (see below) +client_id = # your own Spotify app, used only for search (below) backend = auto # auto | soloist | librespot -device_name = trill # how Soloist shows up in Spotify Connect +device_name = trill # how Soloist shows up in Spotify Connect soloist_cache_mb = 200 -soloist_ws = # host:port of a Soloist you already run, instead of spawning one -eq = on # off = never run the EQ process -art = on # off = no album art (and no terminal capability query) -mouse = on # off = no clicks or wheel; the terminal keeps its own text selection +soloist_ws = # host:port of a Soloist you already run, instead of starting one +eq = on # off = don't run the EQ at all +art = on # off = no album art (and no terminal query) +mouse = on # off = no clicks or wheel; the terminal keeps its own selection ```
-Better search (recommended) - -Playlists, liked songs, albums and artists all use librespot's own connection, so the public Web API's limits don't apply to them. Search, however, uses the Web API. +Better search -Without your own app, search borrows librespot's shared token, which every librespot app uses, so Spotify rate-limits it most of the time. To keep search fast either way, trill always runs a basic search alongside the Web API one (about 0.3 s), and after a rate-limit error it stops asking the Web API for 2 minutes, doubling with each further error up to 32 minutes. The basic search finds songs, plus the albums and artists of those songs, but no playlists. +Search is the one thing that uses the public Web API. Without your own app it borrows librespot's shared token, which Spotify rate-limits most of the time, so trill always runs a basic search alongside it (about 0.3 s). The basic one finds songs and their albums and artists, but no playlists. After a rate-limit error trill pauses the Web API for 2 minutes, doubling up to 32. -For reliable full search (tracks, albums, playlists and artists): +For full search (songs, albums, playlists and artists) every time: -1. Go to https://developer.spotify.com/dashboard, click **Create app**, and choose Web API. +1. At https://developer.spotify.com/dashboard, **Create app** with the Web API. 2. Add the redirect URI `http://127.0.0.1:8898/login`. -3. Put the Client ID in the config as `client_id = …`. On the next start, trill asks you to log in once more, for search only. +3. Put its Client ID in the config as `client_id = …`. trill asks you to log in once more, for search only. -The status line shows which search path answered: `web api` (your app), `web api*` (the shared token), or "no playlists" (the basic search). +The status line says which one answered: `web api` (your app), `web api*` (the shared token) or "no playlists" (the basic search). +
+ +
+Your data + +Everything trill keeps is plain text: + +| | What | +|---|---| +| `~/.config/trill/` | `config`, `soloist_api_key` | +| `~/.local/share/trill/audio_settings` | your keyboard settings, sorts per list, past searches | +| `~/.local/share/trill/plays` | what you played, for For You (`time`, song, title, artist per line) | +| `~/.local/share/trill/not_interested` | songs you pressed `X` on | +| `~/.local/share/trill/soloist-data/` | this computer's Soloist pairing (don't copy it to another computer) | +| `~/.cache/trill/` | your login, lists, logs; safe to delete (you'd log in again) | + +To take your history and settings to another computer, copy `audio_settings`, `plays` and `not_interested`. `trill --logout` forgets the login.
macOS and Windows notes -- **Which machines:** Apple Silicon Macs and x86_64 Windows, because those are the Soloist builds Spotify publishes. An Intel Mac can still build trill and try `backend = librespot`, if your account still works with librespot. ARM Windows runs the x86_64 build through emulation. -- **Same paths as Linux:** `~/.config/trill`, `~/.cache/trill` and `~/.local/share/trill` (on Windows, under `C:\Users\`), not `~/Library` or `%APPDATA%`. -- **No EQ.** It's a PipeWire filter, and PipeWire is Linux-only. Picking an EQ setting says so instead of starting it. -- **Media keys:** on a Mac, play/pause, next and previous (keyboard, AirPods, Control Center, the lock screen) control trill, and Now Playing shows the song and its cover. Windows has no media-key support yet. Every key inside trill works everywhere, and your phone can control it through Spotify Connect. -- **Album art:** Ghostty, kitty, WezTerm and iTerm2 show the real cover, and so does Windows Terminal. Apple's Terminal can't draw images, so there the cover is coloured half-blocks and looks blurry and blocky; use one of the others on a Mac for a sharp cover. The old Windows console also uses half-blocks. -- **Quitting:** `q` stops Soloist with trill. If trill crashes, Soloist can keep running in the background (Linux stops it automatically). Run `pkill soloist` on a Mac or `taskkill /IM soloist.exe /F` on Windows if that happens. -- The [Numbers](#numbers) were measured on Linux. The glibc memory tricks under *Why it's light* in [Numbers](#numbers) only apply on Linux. +- **Which machines:** Apple Silicon Macs and x86_64 Windows, the Soloist builds Spotify publishes. ARM Windows runs the x86_64 build through emulation. +- **Same paths as Linux:** `~/.config/trill`, `~/.cache/trill` and `~/.local/share/trill` (on Windows, under `C:\Users\`). +- **No EQ:** it's a PipeWire filter, and PipeWire is Linux-only. +- **Media keys:** on a Mac, play/pause, next and previous (keyboard, AirPods, Control Center, the lock screen) control trill, and Now Playing shows the song and cover. Windows has no media-key support yet; your phone can control trill through Spotify Connect. +- **Quitting:** `q` stops Soloist with trill. If trill crashes on a Mac or Windows, Soloist can keep running: `pkill soloist`, or `taskkill /IM soloist.exe /F`. +- The [Numbers](#numbers) were measured on Linux; the memory trimming only applies there. macOS and Windows builds are compiled and tested by CI on every release, but get less everyday use, so an issue helps if something seems off.
Debugging ```bash -TRILL_LOG=debug trill # writes ~/.cache/trill/trill.log -trill --debug-play [spotify:track:…] # play one track headless, print engine events +TRILL_LOG=debug trill # writes ~/.cache/trill/trill.log +trill --debug-play [spotify:track:…] # play one song headless, print the player's events ``` Soloist's own output goes to `~/.cache/trill/soloist.log`.
-## Troubleshooting - -- **"trill is not recognized" or "command not found":** open a new terminal window after installing. -- **"cargo is not recognized":** you only need Rust to build trill yourself. Use the download in step 1. -- **Every song is skipped with "Unavailable":** trill isn't playing through Soloist, and the message says what's missing. Usually the key isn't saved in `~/.config/trill/soloist_api_key` (on Windows, `C:\Users\\.config\trill\soloist_api_key`), or step 4 hasn't been run. -- **Album art looks pixelated or blocky:** your terminal can't display images, so trill draws the cover with coloured blocks. This is always the case in Apple's Terminal, Alacritty and the old Windows console. Use Ghostty, kitty, WezTerm, iTerm2 or Windows Terminal for the real cover. -- **Your phone doesn't list trill:** run `trill --pair` again with the phone on the same Wi-Fi, and allow the firewall prompt. -- **Anything else:** run `TRILL_LOG=debug trill` (on Windows: `$env:TRILL_LOG="debug"; trill`). trill's log is then in `~/.cache/trill/trill.log`, and Soloist's in `~/.cache/trill/soloist.log`. - -> [!NOTE] -> macOS and Windows support is new. If something doesn't work there, an issue with the log helps. - -> [!TIP] -> Setting trill up on a second computer? Copy only `~/.config/trill/soloist_api_key` and pair again there. Don't copy `~/.local/share/trill`: it holds this computer's Soloist identity, and two players sharing one identity keep taking playback from each other. - ## FAQ **Why not just librespot?** -On many accounts, Spotify no longer hands librespot the keys to decrypt audio. trill still uses librespot for everything except playback, and you can switch to it with `backend = librespot` if your account still works with it. +On many accounts Spotify no longer gives librespot the keys to decrypt audio. trill still uses librespot for everything except playback, and `backend = librespot` switches to it if your account still works with it. **Does it work without Premium?** -No. Both Soloist and librespot need a Premium account. +No. Soloist and librespot both need Premium. **Only CachyOS?** -No. It's tuned and tested there, but any Linux with PipeWire or PulseAudio works, and so do Apple Silicon Macs and Windows PCs (see [Get started](#get-started)). +No. It's made and measured there, but any Linux with PipeWire or PulseAudio works, and so do Apple Silicon Macs and Windows PCs. **Can I use it in WSL?** -The Linux build should work under WSL2 with WSLg, which provides the audio. Pairing your phone with Soloist needs WSL's mirrored networking, though, so on Windows the native build is the easier choice. +The Linux build should work under WSL2 with WSLg for audio, but pairing your phone needs WSL's mirrored networking, so the native Windows build is easier. **Why does it ask me to log in twice?** -It only does if you set your own `client_id`. That second login is for search alone. +Only if you set your own `client_id`: that second login is for search alone. + +**Does For You send my listening history anywhere?** +No. The play log stays on your computer. Spotify sees the requests For You makes (radio and artist pages for a few seeds), the same kind trill makes while you browse. See [For You](#for-you). diff --git a/assets/readme/different.svg b/assets/readme/different.svg new file mode 100644 index 0000000..34db6f0 --- /dev/null +++ b/assets/readme/different.svg @@ -0,0 +1,34 @@ + + + + + + + +what's different + + +Plays where librespot can't +Audio comes from Soloist, Spotify's own player, +so it works on accounts that refuse librespot. + + +Small and quiet +About 17.4 MB of memory, and no CPU or timers +while idle. It redraws only when something changes. + + +For You, worked out here +Suggestions from what you play, ranked on your +computer. Your play history stays on it. + + +Your whole library +Playlists, folders, pins, albums, artists, lyrics. +Through Spotify's own API: no Web API limits. + diff --git a/assets/readme/features.svg b/assets/readme/features.svg index 5818a99..05e2667 100644 --- a/assets/readme/features.svg +++ b/assets/readme/features.svg @@ -1,57 +1,66 @@ - + - - - - -what it does - -press ? in trill for every key - -L -Synced lyrics -the line lights up as it's sung - -i -Album art -real images in kitty, Ghostty, iTerm2 - -e -10-band EQ -11 presets, only trill's audio - -s -Smart shuffle -a Spotify pick after every three - -x -Crossfade -Spotify's own, gapless, 320 kbps - -I -Private session -hidden from friends and Discord - -f -Like, save, follow -songs, albums and artists - -A -Playlists -add to yours or remove from them - -/ -Search -songs, albums, artists, playlists - -y -Copy link -any song, album or playlist - -Also: media keys · lock screen · KDE media widget · your phone via Spotify Connect + + + + + +features + +press ? in trill for every key + +/ +Search +songs, albums, artists, playlists + +✦ +For You +picks from what you play, X to skip + +s +Smart shuffle +a recommendation after every three + +L +Synced lyrics +the line being sung stays in view + +i +Album art +real images, colour blocks elsewhere + +e +10-band EQ +11 presets, Linux (PipeWire) + +x +Crossfade +Spotify's own, gapless at 320 kbps + +z +Sleep timer +15–90 min or the end of the song + +F +Find in a list +narrows as you type, o sorts it + +f +Like, save, follow +A adds to playlists, ✓ shows where + +I +Private session +hidden from friends, Discord too + + +Media keys +MPRIS on Linux, Now Playing on macOS +plus pins and folders · artist pages with play counts · themes · the mouse diff --git a/assets/readme/footprint.svg b/assets/readme/footprint.svg deleted file mode 100644 index 3de943c..0000000 --- a/assets/readme/footprint.svg +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - -footprint - -88 MB in all · PSS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -trill -22 MB - -Soloist -54 MB - -crash reporter -8 MB - -EQ, when on -4 MB - -0% -trill CPU, idle -0.1–0.3% -trill CPU, playing -~2.5% -Soloist, playing -9 MB -one binary - diff --git a/assets/readme/foryou.svg b/assets/readme/foryou.svg new file mode 100644 index 0000000..80168c3 --- /dev/null +++ b/assets/readme/foryou.svg @@ -0,0 +1,44 @@ + + + + + + + +how For You works + +your play history stays on your computer + + +1 +What you play +each song after 30 s, +older plays count less + + + +2 +Your seeds +your top songs and +your top artists + + + +3 +Ask Spotify +their radio, related +artists; kept 12 hours + + + +4 +Ranked here +liked: left out +played a lot: down +No artist gets more than 3 songs. The Why column says where each came from; X hides one for good. + diff --git a/assets/readme/get-started.svg b/assets/readme/get-started.svg index 9365662..ba0c8bf 100644 --- a/assets/readme/get-started.svg +++ b/assets/readme/get-started.svg @@ -1,41 +1,39 @@ - + - - - - -get started - -~10 minutes, once · Spotify Premium -01 -Install -$ -curl -fsSL …/trill-linux-x86_64.tar.gz | tar -xz - -02 -Get a Soloist key -developer.spotify.com → Soloist API Key - -03 -Save it -~/.config/trill/soloist_api_key - -04 -Get Soloist -$ -trill --update-soloist - -05 -Pair your phone -$ -trill --pair - -06 -Play -$ -trill + + + + + +get started + +about ten minutes, once + +1 +Install +one command, +see below + + +2 +Soloist key +free, from Spotify's +developer dashboard + + +3 +Get Soloist +trill --update-soloist +downloads it + + +4 +Pair, play +trill --pair once, +then just trill diff --git a/assets/readme/hero.svg b/assets/readme/hero.svg index ec61c7e..c6d365f 100644 --- a/assets/readme/hero.svg +++ b/assets/readme/hero.svg @@ -1,42 +1,42 @@ - + - - - - __ _ ____ - / /______(_) / / - / __/ ___/ / / / -/ /_/ / / / / / -\__/_/ /_/_/_/ - -Spotify in your terminal. -Lighter than the tab you'd open to look it up. - -Midnight City -M83 -vol 70% - -⇄ -↻ - -1:42 - -4:03 + + + + __ _ ____ + / /______(_) / / + / __/ ___/ / / / +/ /_/ / / / / / +\__/_/ /_/_/_/ +Spotify in your terminal. +Spotify's own player inside. Quiet when idle. + +Dreams +Fleetwood Mac + +⇄ +↻ +⊘ +1:42 + + +4:17 -~20 MB -RAM, 3,901 songs open - -0% -CPU while idle - -~2 ms -key press to frame - -~30 ms -launch to library +17.4 MB +memory at start + +0% +CPU while idle + +~50 ms +to your library + +6.6 MB +one program diff --git a/assets/readme/how-it-works.svg b/assets/readme/how-it-works.svg index a30b0ec..9a7f3d5 100644 --- a/assets/readme/how-it-works.svg +++ b/assets/readme/how-it-works.svg @@ -1,56 +1,52 @@ - + - - - - -how it works - -two connections, one thread - - -trill -One async thread for UI -and network. Redraws only -on change. Never polls. - - -spotify -Library, search, lyrics, -edits, audio, Connect. - - -your desktop -Media keys, lock screen, -KDE widget (MPRIS). - - -soloist -Spotify's own player. -320 kbps, crossfade. - - -pipewire -Through the EQ when on. - - -librespot - - -no Web API limits - - -mpris - - -local websocket - - -audio, connect - - + + + + + +how it works + +Premium account · no Web API limits + +Spotify +your library, search, +lyrics, radio: through +librespot's session + +On disk +lists, settings, plays: +open at once, refresh +in the background + +trill +one async thread: +screen + network +redraws only on change +keys on their own thread + +Soloist +Spotify's own player, +driven over a WebSocket + +Desktop +media keys, widgets: +MPRIS · Now Playing +your phone: Connect + +Sound +PipeWire, with the EQ +when it's on (Linux); +CoreAudio · Windows + +browse + + + + diff --git a/assets/readme/keys.svg b/assets/readme/keys.svg index d343078..800c0b0 100644 --- a/assets/readme/keys.svg +++ b/assets/readme/keys.svg @@ -1,144 +1,104 @@ - + - - - - -playback - -Space -play / pause - -n - -p -next / previous - -← - -→ -seek ±10 s (also , and .) - -+ - -- -volume ±5% - -s -shuffle: off → on → smart - -r -repeat: off → all → one - -x -crossfade off · 3 · 5 · 8 · 12 s - -P -play everything in the list - -c -show the queue - - -library - -f -like · save album · follow artist - -a -add to queue - -A -add to / remove from a playlist - -D - -D -remove from the open playlist - -y -copy link of the highlighted row - -Y -copy link of the open list - -I -private session on / off - - -browse - -↑ - -↓ - -j - -k -move - -g - -G -top / bottom (PgUp, PgDn) - -Tab - -h - -l -switch pane - -Enter -play / open - -Esc -back (also Backspace) - -/ -search - -o - -O -next / previous sort order - -w -jump to the playing song - -u - -U -open the song's album / artist - -R -reload the list - - -view - -L -lyrics - -i -album art on / off - -t -next colour theme - -e - -E -next EQ preset / EQ panel - -? -every key, in trill - -q -quit (pauses first) + + + + + +keys + +? in trill shows them all +Move + +↑↓ jk +move + +g G +top / bottom + +Tab h l +switch pane + +Enter +open · play + +Esc +back + +w +to what's playing + +? +every key +Play + +Space +play / pause + +n p +next / previous + +← → +seek ±10 s + ++ - +volume ±5% + +s r +shuffle · repeat + +x z +crossfade · sleep + +P +play all +Library + +f +like · save · follow + +a +add to queue + +A +add to a playlist + +D D +remove + +X +not interested + +I +private session + +y Y +copy link +Find + +/ +search + +F +find in a list + +o O +sort this list + +u U +album · artist + +c +the queue + +L i t +lyrics · art · theme + +e E +EQ diff --git a/assets/readme/make.py b/assets/readme/make.py new file mode 100644 index 0000000..a6df7a1 --- /dev/null +++ b/assets/readme/make.py @@ -0,0 +1,599 @@ +#!/usr/bin/env python3 +"""Builds the README graphics in assets/readme/: hand-laid SVGs in trill's look. + + TRILL_FONTS=/path/to/JetBrainsMono-2.304/fonts/ttf python3 assets/readme/make.py + +Fonts: JetBrains Mono (SIL OFL 1.1, https://github.com/JetBrains/JetBrainsMono) for text, DejaVu +Sans Mono (free license) for the few symbols it lacks. Each SVG embeds a renamed subset of just the +characters it uses, so it looks the same on every machine and stays small. Needs fonttools + brotli. + +The screenshots are real: `screens/*.ansi` are `tmux capture-pane -e` captures of trill itself +(140×42), rendered cell by cell; `screens/capture.sh` makes them. The only edit: the sidebar's +playlist names are swapped for neutral ones, since they're someone's own library. Borders, +half-block cover art and the progress bar are drawn as shapes, so they join without gaps at any zoom. + +Every number below is in NUMBERS, measured on a release build (see the README's Numbers section). +""" + +import base64, html, io, os, re +from pathlib import Path + +from fontTools import subset +from fontTools.ttLib import TTFont + +HERE = Path(__file__).resolve().parent +FONTS = Path(os.environ.get("TRILL_FONTS", "")) +JB = {400: FONTS / "JetBrainsMono-Regular.ttf", 500: FONTS / "JetBrainsMono-Medium.ttf", 600: FONTS / "JetBrainsMono-SemiBold.ttf"} +FALLBACK = Path(os.environ.get("TRILL_FALLBACK", "/usr/share/fonts/TTF/DejaVuSansMono.ttf")) + +# palette: trill's greys and its default theme (src/theme.rs: "spotify", green → cyan) +BG, EDGE, PANE, TILE = "#0d0d0d", "#1f1f1f", "#2a2a2a", "#1b1b1b" +TXT, MID, DIM = "#ececec", "#8f8f8f", "#5b5b5b" +ACC, ACC2 = "#1ed760", "#00afeb" +W = 880 + +JB_CMAP = set(TTFont(JB[400]).getBestCmap()) if JB[400].exists() else set() + +LOGO = [ # src/ui.rs + " __ _ ____", + " / /______(_) / /", + " / __/ ___/ / / / ", + "/ /_/ / / / / / ", + "\\__/_/ /_/_/_/ ", +] + + +def woff2(path, text, family): + opts = subset.Options() + opts.flavor = "woff2" + opts.layout_features = [] + opts.hinting = False + opts.notdef_outline = True + opts.name_IDs = [1, 2, 4, 6] + f = subset.load_font(str(path), opts) + s = subset.Subsetter(opts) + s.populate(text=text) + s.subset(f) + for rec in f["name"].names: # renamed, as the OFL asks of modified versions + if rec.nameID in (1, 4): + rec.string = family + elif rec.nameID == 6: + rec.string = family.replace(" ", "") + buf = io.BytesIO() + subset.save_font(f, buf, opts) + return base64.b64encode(buf.getvalue()).decode() + + +class Svg: + def __init__(self, w, h, label): + self.w, self.h, self.label = w, h, label + self.els = [] + self.used = {400: set(), 500: set(), 600: set()} + self.fallback = set() + self.defs = [] + + def add(self, s): + self.els.append(s) + + def rect(self, x, y, w, h, fill, rx=0, stroke=None, extra=""): + st = f' stroke="{stroke}"' if stroke else "" + rr = f' rx="{rx}"' if rx else "" + self.add(f'') + + def text(self, x, y, s, size=13, weight=400, fill=TXT, anchor="start", ls=None, fit=None): + for c in s: + (self.used[weight] if ord(c) in JB_CMAP or ord(c) < 128 else self.fallback).add(c) + attrs = f' letter-spacing="{ls}"' if ls is not None else "" + if fit: + attrs += f' textLength="{fit:.2f}" lengthAdjust="spacingAndGlyphs"' + self.add(f'{html.escape(s, quote=False)}') + + def gradient(self, gid, a=ACC, b=ACC2, x2="1", y2="0"): + self.defs.append(f'') + + def card(self): + self.rect(0, 0, self.w, self.h, BG, rx=6) + self.rect(0.5, 0.5, self.w - 1, self.h - 1, "none", rx=6, stroke=EDGE) + + def pane(self, x, y, w, h, title, note=""): + """A box with its title set into the top edge, like a pane in the app.""" + self.rect(x + 0.5, y + 0.5, w, h, "none", rx=3, stroke=PANE) + tw = len(title) * 13 * 0.6 + 14 + self.rect(x + 12, y - 2, tw, 5, BG) + self.text(x + 18, y + 4.5, title, 13, 500, MID) + if note: + nw = len(note) * 12 * 0.6 + 14 + self.rect(x + w - 10 - nw, y - 2, nw, 5, BG) + self.text(x + w - 4, y + 4.5, note, 12, 400, DIM, "end") + + def save(self, name): + faces = [] + for wgt, chars in self.used.items(): + if chars: + faces.append(f"@font-face{{font-family:tm;font-weight:{wgt};src:url(data:font/woff2;base64,{woff2(JB[wgt], ''.join(sorted(chars)), 'trillmono')})}}") + if self.fallback: + faces.append(f"@font-face{{font-family:tf;src:url(data:font/woff2;base64,{woff2(FALLBACK, ''.join(sorted(self.fallback)), 'trillmono fallback')})}}") + style = "\n".join(faces) + "\ntext{font-family:tm,tf,ui-monospace,SFMono-Regular,Menlo,Consolas,'DejaVu Sans Mono',monospace}" + defs = f"{''.join(self.defs)}" if self.defs else "" + out = ( + f'\n' + f"\n{defs}\n" + "\n".join(self.els) + "\n\n" + ) + (HERE / name).write_text(out, encoding="utf-8") + print(f"{name}: {len(out) / 1024:.1f} KB") + + +def pill(s, x, y, label, lit=True, size=12): + w = len(label) * size * 0.6 + 12 + if lit: + s.rect(x, y - size + 1, w, size + 6, ACC, rx=2) + s.text(x + w / 2, y + 1, label, size, 600, BG, "middle") + else: + s.text(x + w / 2, y + 1, label, size, 400, DIM, "middle") + return w + + +def progress_bar(s, x, y, w, frac, h=5, gid="pg"): + s.rect(x, y, w, h, TILE) + s.rect(x, y, w * frac, h, f"url(#{gid})") + + +def pie(s, cx, cy, r, frac, color=ACC): + """◔ ◑ ◕ as shapes (fonts disagree on them).""" + import math + + s.add(f'') + if frac >= 1: + s.add(f'') + return + a = frac * 2 * math.pi + x2, y2 = cx + r * math.sin(a), cy - r * math.cos(a) + big = 1 if frac > 0.5 else 0 + s.add(f'') + + +# ---------------------------------------------------------------------------- screenshots + +PAL16 = ["#1e1e1e", "#f2777a", "#99cc99", "#ffcc66", "#6699cc", "#cc99cc", "#66cccc", "#d0d0d0", "#6b6b6b", "#ff8c8c", "#b5e8b5", "#ffe08a", "#8fb8e8", "#e0b0e0", "#8ce0e0", "#ffffff"] +TERM_FG, TERM_BG = "#d4d4d4", "#101012" + + +def xterm256(n): + if n < 16: + return PAL16[n] + if n < 232: + n -= 16 + lv = [0, 95, 135, 175, 215, 255] + return "#%02x%02x%02x" % (lv[n // 36], lv[n // 6 % 6], lv[n % 6]) + v = 8 + (n - 232) * 10 + return "#%02x%02x%02x" % (v, v, v) + + +def mix(a, b, t): + pa = [int(a[i : i + 2], 16) for i in (1, 3, 5)] + pb = [int(b[i : i + 2], 16) for i in (1, 3, 5)] + return "#%02x%02x%02x" % tuple(round(x + (y - x) * t) for x, y in zip(pa, pb)) + + +def parse_ansi(path, cols): + """tmux capture-pane -e → rows of cells (char, fg, bg, bold).""" + rows = [] + for line in path.read_text(encoding="utf-8").split("\n"): + fg, bg, bold, dim, rev = None, None, False, False, False + cells = [] + for tok in re.split(r"(\x1b\[[0-9;]*m)", line): + if tok.startswith("\x1b["): + codes = [int(c) if c else 0 for c in tok[2:-1].split(";")] or [0] + i = 0 + while i < len(codes): + c = codes[i] + if c == 0: + fg, bg, bold, dim, rev = None, None, False, False, False + elif c == 1: + bold = True + elif c == 2: + dim = True + elif c == 22: + bold = dim = False + elif c == 7: + rev = True + elif c == 27: + rev = False + elif 30 <= c <= 37: + fg = PAL16[c - 30] + elif 90 <= c <= 97: + fg = PAL16[c - 90 + 8] + elif 40 <= c <= 47: + bg = PAL16[c - 40] + elif 100 <= c <= 107: + bg = PAL16[c - 100 + 8] + elif c == 39: + fg = None + elif c == 49: + bg = None + elif c in (38, 48) and i + 1 < len(codes): + if codes[i + 1] == 5: + col = xterm256(codes[i + 2]) + i += 2 + else: + col = "#%02x%02x%02x" % tuple(codes[i + 2 : i + 5]) + i += 4 + if c == 38: + fg = col + else: + bg = col + i += 1 + continue + for ch in tok: + f, b = fg or TERM_FG, bg or TERM_BG + if rev: + f, b = b, f + if dim: + f = mix(f, b, 0.45) + cells.append((ch, f, b, bold)) + cells += [(" ", TERM_FG, TERM_BG, False)] * (cols - len(cells)) + rows.append(cells[:cols]) + return rows + + +BOX = set("─│╭╮╰╯") +BLOCKS = {"▀": "top", "▄": "bottom", "█": "full", "▏": 1, "▎": 2, "▍": 3, "▌": 4, "▋": 5, "▊": 6, "▉": 7} + + +def screenshot(name, ansi, label, cols=140, rows=42, crop=None): + cells = parse_ansi(HERE / "screens" / ansi, cols)[:rows] + if crop: + cells = cells[crop[0] : crop[1]] + fs, cw, lh = 12.5, 7.5, 16.5 + pad, bar = 16, 30 + tw, th = cols * cw, len(cells) * lh + sw, sh = tw + pad * 2, th + pad * 2 + bar + s = Svg(round(sw), round(sh), label) + s.rect(0, 0, sw, sh, TERM_BG, rx=10) + s.rect(0.5, 0.5, sw - 1, sh - 1, "none", rx=10, stroke="#2c2c30") + s.rect(1, 1, sw - 2, bar - 1, "#18181b", rx=9) + s.rect(1, bar - 8, sw - 2, 8, "#18181b") + s.add(f'') + for i, c in enumerate(["#ff5f57", "#febc2e", "#28c840"]): + s.add(f'') + s.text(sw / 2, bar / 2 + 4.5, "trill", 12, 500, "#9a9aa0", "middle") + ox, oy = pad, bar + pad + for r, row in enumerate(cells): + y = oy + r * lh + # backgrounds, merged into runs + c = 0 + while c < cols: + b = row[c][2] + e = c + while e < cols and row[e][2] == b: + e += 1 + if b != TERM_BG: + s.rect(ox + c * cw, y, (e - c) * cw + 0.3, lh + 0.3, b) + c = e + # shapes for borders and blocks; text in runs of one style + c = 0 + while c < cols: + ch, f, b, bold = row[c] + x = ox + c * cw + if ch in BOX: + mx, my = x + cw / 2, y + lh / 2 + d = {"─": f"M{x} {my}H{x + cw}", "│": f"M{mx} {y}V{y + lh}", + "╭": f"M{x + cw} {my}H{mx + 3}Q{mx} {my} {mx} {my + 3}V{y + lh}", "╮": f"M{x} {my}H{mx - 3}Q{mx} {my} {mx} {my + 3}V{y + lh}", + "╰": f"M{mx} {y}V{my - 3}Q{mx} {my} {mx + 3} {my}H{x + cw}", "╯": f"M{mx} {y}V{my - 3}Q{mx} {my} {mx - 3} {my}H{x}"}[ch] + s.add(f'') + c += 1 + continue + if ch in BLOCKS: + k = BLOCKS[ch] + if k == "top": + s.rect(x, y, cw + 0.3, lh / 2 + 0.2, f) + elif k == "bottom": + s.rect(x, y + lh / 2, cw + 0.3, lh / 2 + 0.3, f) + elif k == "full": + s.rect(x, y, cw + 0.3, lh + 0.3, f) + else: + s.rect(x, y, cw * k / 8, lh + 0.3, f) + c += 1 + continue + if ch == "⏸": + s.rect(x + 1.5, y + 4, 1.8, lh - 8, f) + s.rect(x + 4.6, y + 4, 1.8, lh - 8, f) + c += 1 + continue + if ch == "⤓": # no font here has it: an arrow down onto a bar + mx = x + cw / 2 + s.add(f'') + s.rect(x + 1, y + lh - 4.6, cw - 2, 1.4, f) + c += 1 + continue + e = c + while e < cols and row[e][0] not in BOX and row[e][0] not in BLOCKS and row[e][0] not in "⏸⤓" and row[e][1] == f and row[e][3] == bold: + e += 1 + run = "".join(x[0] for x in row[c:e]) + if run.strip(): + s.text(x, y + lh - 4.5, run, fs, 600 if bold else 400, f, fit=(e - c) * cw) + c = e + s.save(name) + + + +# ---------------------------------------------------------------------------- numbers +# Measured on the v0.6.0 release download, i9-14900HX, CachyOS, Soloist backend, a library of 3,953 +# liked songs and 110 playlists, in tmux at 140×42 (see the README for how). Memory is PSS. +NUMBERS = { + "pss_start": "17.4 MB", + "pss_playing": "20.6 MB", + "pss_foryou": "20.2 MB", + "soloist": "~49 MB", + "cpu_playing": "0.2%", + "first_frame": "~50 ms", + "binary": "6.6 MB", + "foryou_fresh": "~1.5 s", + "foryou_reopen": "7 ms", +} +N = NUMBERS + + +# ---------------------------------------------------------------------------- hero + + +def hero(): + h = 352 + s = Svg(W, h, f"trill: Spotify in your terminal. It plays through Spotify's own player, Soloist. About {N['pss_start']} of memory at start, 0% CPU while idle, the library on screen in {N['first_frame']}, one {N['binary']} program.") + s.gradient("lg", x2="1", y2="0") + s.gradient("pg") + s.card() + for i, row in enumerate(LOGO): + s.text(52, 74 + i * 25, row, 22, 600, "url(#lg)") + x = 400 + s.text(x, 82, "Spotify in your terminal.", 27, 500, TXT, ls="-.6") + s.text(x, 112, "Spotify's own player inside. Quiet when idle.", 14, 400, MID) + s.add(f'') + s.text(x + 18, 160, "Dreams", 13, 600, ACC) + s.text(x + 18 + 8 * 7.8, 160, "Fleetwood Mac", 13, 400, MID) + for i, (lit, icon) in enumerate([(True, "⇄"), (False, "↻"), (False, "⊘")]): + pill(s, W - 44 - 3 * 26 + i * 26, 160, icon, lit) + s.text(x, 186, "1:42", 11, 400, MID) + progress_bar(s, x + 36, 180, W - 44 - x - 36 - 38, 0.4) + s.text(W - 44, 186, "4:17", 11, 400, MID, "end") + s.add(f'') + stats = [(N["pss_start"], "memory at start"), ("0%", "CPU while idle"), (N["first_frame"], "to your library"), (N["binary"], "one program")] + cw = (W - 88) / 4 + for i, (big, small) in enumerate(stats): + cx = 44 + i * cw + if i: + s.add(f'') + s.text(cx, 290, big, 25, 500, TXT, ls="-.5") + s.text(cx, 314, small, 12, 400, MID) + s.save("hero.svg") + + +# ---------------------------------------------------------------------------- what's different + + +def different(): + cards = [ + ("Plays where librespot can't", ["Audio comes from Soloist, Spotify's own player,", "so it works on accounts that refuse librespot."]), + ("Small and quiet", [f"About {N['pss_start']} of memory, and no CPU or timers", "while idle. It redraws only when something changes."]), + ("For You, worked out here", ["Suggestions from what you play, ranked on your", "computer. Your play history stays on it."]), + ("Your whole library", ["Playlists, folders, pins, albums, artists, lyrics.", "Through Spotify's own API: no Web API limits."]), + ] + h = 290 + s = Svg(W, h, "What's different about trill: " + "; ".join(f"{t}: " + " ".join(ls) for t, ls in cards)) + s.card() + s.pane(24, 26, W - 49, h - 53, "what's different") + cw, ch = (W - 88 - 14) / 2, 94 + for i, (title, lines) in enumerate(cards): + x, top = 44 + (i % 2) * (cw + 14), 52 + (i // 2) * (ch + 14) + s.rect(x + 0.5, top + 0.5, cw, ch, TILE, rx=4, stroke=PANE) + s.rect(x + 16, top + 20, 3, 18, ACC, rx=1.5) + s.text(x + 28, top + 34, title, 14, 600, TXT) + for j, l in enumerate(lines): + s.text(x + 16, top + 60 + j * 17, l, 11, 400, MID) + s.save("different.svg") + + +# ---------------------------------------------------------------------------- features + + +def features(): + items = [ + ("/", "Search", "songs, albums, artists, playlists"), + ("✦", "For You", "picks from what you play, X to skip"), + ("s", "Smart shuffle", "a recommendation after every three"), + ("L", "Synced lyrics", "the line being sung stays in view"), + ("i", "Album art", "real images, colour blocks elsewhere"), + ("e", "10-band EQ", "11 presets, Linux (PipeWire)"), + ("x", "Crossfade", "Spotify's own, gapless at 320 kbps"), + ("z", "Sleep timer", "15–90 min or the end of the song"), + ("F", "Find in a list", "narrows as you type, o sorts it"), + ("f", "Like, save, follow", "A adds to playlists, ✓ shows where"), + ("I", "Private session", "hidden from friends, Discord too"), + ("▶", "Media keys", "MPRIS on Linux, Now Playing on macOS"), + ] + h = 448 + s = Svg(W, h, "What trill does, by key: " + "; ".join(f"{k}: {a}, {b}" for k, a, b in items) + ". Plus pins and folders, artist pages with play counts, themes and the mouse.") + s.card() + s.pane(24, 26, W - 49, h - 53, "features", "press ? in trill for every key") + for i, (k, a, b) in enumerate(items): + col, row = i % 2, i // 2 + x, y = 52 + col * 400, 62 + row * 56 + s.rect(x + 0.5, y + 0.5, 29, 29, TILE, rx=3, stroke=PANE) + if k == "▶": + s.add(f'') + else: + s.text(x + 15, y + 20, k, 14, 600, ACC, "middle") + s.text(x + 46, y + 12, a, 14, 500, TXT) + s.text(x + 46, y + 30, b, 12, 400, MID) + s.text(W / 2, h - 44, "plus pins and folders · artist pages with play counts · themes · the mouse", 12, 400, DIM, "middle") + s.save("features.svg") + + +# ---------------------------------------------------------------------------- for you + + +def foryou(): + h = 280 + s = Svg(W, h, "How For You works. 1: what you play: every song played for 30 seconds, logged on your computer, older plays counting less. 2: your seeds: your top songs and top artists. 3: Spotify's radio of those songs and the artists related to yours, fetched at once and kept for 12 hours. 4: ranked here: liked songs left out, songs you play a lot pushed down, no one artist takes over, and X hides a song for good. Your play history stays on your computer.") + s.card() + s.pane(24, 26, W - 49, h - 53, "how For You works", "your play history stays on your computer") + steps = [ + ("1", "What you play", ["each song after 30 s,", "older plays count less"]), + ("2", "Your seeds", ["your top songs and", "your top artists"]), + ("3", "Ask Spotify", ["their radio, related", "artists; kept 12 hours"]), + ("4", "Ranked here", ["liked: left out", "played a lot: down"]), + ] + s.defs.append(f'') + cw = (W - 88 - 3 * 28) / 4 + for i, (n, title, lines) in enumerate(steps): + x = 44 + i * (cw + 28) + top = 60 + hot = i == 3 + s.rect(x + 0.5, top + 0.5, cw, 128, TILE, rx=4, stroke=ACC if hot else PANE) + s.add(f'') + s.text(x + 26, top + 34.5, n, 13, 600, BG if hot else TXT, "middle") + s.text(x + 16, top + 70, title, 14, 600, ACC if hot else TXT) + for j, l in enumerate(lines): + s.text(x + 16, top + 94 + j * 17, l, 11.5, 400, MID) + if i < 3: + ax = x + cw + 4 + s.add(f'') + s.text(W / 2, 222, "No artist gets more than 3 songs. The Why column says where each came from; X hides one for good.", 12, 400, MID, "middle") + s.save("foryou.svg") + + +# ---------------------------------------------------------------------------- get started + + +def start(): + steps = [ + ("1", "Install", ["one command,", "see below"]), + ("2", "Soloist key", ["free, from Spotify's", "developer dashboard"]), + ("3", "Get Soloist", ["trill --update-soloist", "downloads it"]), + ("4", "Pair, play", ["trill --pair once,", "then just trill"]), + ] + h = 190 + s = Svg(W, h, "Get started in four steps, about ten minutes, once. 1: install trill with one command. 2: get a free Soloist API key from Spotify's developer dashboard and save it. 3: run trill --update-soloist to download Spotify's player. 4: run trill --pair once with your phone, then just trill.") + s.card() + s.pane(24, 26, W - 49, h - 53, "get started", "about ten minutes, once") + cw = (W - 88 - 3 * 24) / 4 + s.defs.append(f'') + for i, (n, title, lines) in enumerate(steps): + x = 44 + i * (cw + 24) + top = 54 + s.add(f'') + s.text(x + 18, top + 27, n, 14, 600, BG, "middle") + s.text(x + 40, top + 27, title, 15, 600, TXT) + for j, l in enumerate(lines): + s.text(x + 40, top + 52 + j * 18, l, 12, 400, MID) + if i < 3: + ax = x + cw - 6 + s.add(f'') + s.save("get-started.svg") + + +# ---------------------------------------------------------------------------- numbers + + +def numbers(): + h = 300 + s = Svg(W, h, f"Footprint, measured on an i9-14900HX, memory as PSS. trill at start: {N['pss_start']}; playing from Liked Songs, 3,953 songs: {N['pss_playing']}; with For You open: {N['pss_foryou']}; Soloist, Spotify's player, while playing: {N['soloist']}. CPU: 0% idle and paused, about {N['cpu_playing']} playing. The library on screen {N['first_frame']} after launch; For You worked out in {N['foryou_fresh']} and reopened in {N['foryou_reopen']}.") + s.gradient("pg") + s.card() + s.pane(24, 26, W - 49, h - 53, "footprint", "measured · PSS · i9-14900HX") + mb = lambda v: float(v.strip("~ MB")) + bars = [("trill", "at start", N["pss_start"], True), ("trill", "playing, 3,953 liked songs", N["pss_playing"], True), ("trill", "with For You open", N["pss_foryou"], True), ("Soloist", "Spotify's player, playing", N["soloist"], False)] + full = max(mb(b[2]) for b in bars) + x0, bw = 330, W - 330 - 140 + for i, (who, what, label, ours) in enumerate(bars): + y = 66 + i * 34 + s.text(52, y + 13, who, 13, 600 if ours else 400, ACC if ours else MID) + s.text(132, y + 13, what, 12, 400, MID) + w = bw * mb(label) / full + s.rect(x0, y + 2, w, 14, "url(#pg)" if ours else "#3a3a3a", rx=2) + s.text(x0 + w + 10, y + 14, label, 13, 500, TXT if ours else MID) + s.add(f'') + stats = [("0%", "CPU idle and paused"), (N["cpu_playing"], "CPU playing"), (N["first_frame"], "launch to library"), (N["foryou_reopen"], "reopen For You")] + cw = (W - 104) / 4 + for i, (big, small) in enumerate(stats): + x = 52 + i * cw + s.text(x, 240, big, 20, 500, TXT, ls="-.4") + s.text(x, 260, small, 12, 400, MID) + s.save("numbers.svg") + + +# ---------------------------------------------------------------------------- how it works + + +def how(): + h = 330 + s = Svg(W, h, "How it works. trill runs its screen and networking on one async thread, with keys read on a thread of their own. It browses your library through librespot's session, the same private API the official apps use, so no Web API limits apply, and keeps your lists on disk so they open at once. It drives Soloist, Spotify's own headless player, over a local WebSocket; Soloist streams from Spotify and plays through PipeWire, with the EQ when it's on. The desktop gets MPRIS on Linux and Now Playing on macOS.") + s.card() + s.pane(24, 26, W - 49, h - 53, "how it works", "Premium account · no Web API limits") + + def box(x, y, w, hgt, title, lines, hot=False): + s.rect(x + 0.5, y + 0.5, w, hgt, TILE if hot else BG, rx=4, stroke=ACC if hot else PANE) + s.text(x + 14, y + 22, title, 13, 600, ACC if hot else TXT) + for j, l in enumerate(lines): + s.text(x + 14, y + 42 + j * 17, l, 11.5, 400, MID) + + def arrow(x1, y1, x2, y2, label=""): + s.add(f'') + if label: + s.text((x1 + x2) / 2, (y1 + y2) / 2 - 6, label, 10.5, 400, DIM, "middle") + + s.defs.append(f'') + box(52, 58, 196, 92, "Spotify", ["your library, search,", "lyrics, radio: through", "librespot's session"]) + box(52, 176, 196, 92, "On disk", ["lists, settings, plays:", "open at once, refresh", "in the background"]) + box(318, 58, 244, 120, "trill", ["one async thread:", "screen + network", "redraws only on change", "keys on their own thread"], hot=True) + box(318, 200, 244, 68, "Soloist", ["Spotify's own player,", "driven over a WebSocket"]) + box(632, 58, 196, 92, "Desktop", ["media keys, widgets:", "MPRIS · Now Playing", "your phone: Connect"]) + box(632, 176, 196, 92, "Sound", ["PipeWire, with the EQ", "when it's on (Linux);", "CoreAudio · Windows"]) + arrow(248, 104, 316, 104, "browse") + arrow(248, 222, 316, 160) + arrow(440, 178, 440, 198) + arrow(562, 104, 630, 104) + arrow(562, 234, 630, 222) + s.save("how-it-works.svg") + + +# ---------------------------------------------------------------------------- keys + + +def keys(): + groups = [ + ("Move", [("↑↓ jk", "move"), ("g G", "top / bottom"), ("Tab h l", "switch pane"), ("Enter", "open · play"), ("Esc", "back"), ("w", "to what's playing"), ("?", "every key")]), + ("Play", [("Space", "play / pause"), ("n p", "next / previous"), ("← →", "seek ±10 s"), ("+ -", "volume ±5%"), ("s r", "shuffle · repeat"), ("x z", "crossfade · sleep"), ("P", "play all")]), + ("Library", [("f", "like · save · follow"), ("a", "add to queue"), ("A", "add to a playlist"), ("D D", "remove"), ("X", "not interested"), ("I", "private session"), ("y Y", "copy link")]), + ("Find", [("/", "search"), ("F", "find in a list"), ("o O", "sort this list"), ("u U", "album · artist"), ("c", "the queue"), ("L i t", "lyrics · art · theme"), ("e E", "EQ")]), + ] + h = 346 + s = Svg(W, h, "Every key, grouped as in trill's help: " + "; ".join(f"{g}: " + ", ".join(f"{k} {d}" for k, d in ks) for g, ks in groups)) + s.card() + s.pane(24, 26, W - 49, h - 53, "keys", "? in trill shows them all") + cw = (W - 88) / 4 + for i, (g, ks) in enumerate(groups): + x = 52 + i * cw + s.text(x, 64, g, 13, 600, ACC) + for j, (k, d) in enumerate(ks): + y = 92 + j * 28 + kw = len(k) * 12 * 0.6 + 12 + s.rect(x + 0.5, y - 14.5, kw, 20, TILE, rx=3, stroke=PANE) + s.text(x + kw / 2, y, k, 12, 600, TXT, "middle") + s.text(x + kw + 8, y, d, 11, 400, MID) + s.save("keys.svg") + + +if __name__ == "__main__": + if not JB[400].exists(): + raise SystemExit("set TRILL_FONTS to JetBrains Mono's fonts/ttf directory (see the top of this file)") + hero() + different() + features() + foryou() + start() + numbers() + how() + keys() + screenshot("screen-library.svg", "screen-library.ansi", "trill playing Dreams by Fleetwood Mac from the album Rumours: the Library sidebar with Liked Songs, Albums, Artists, For You, Queue, Search and playlists, the album cover drawn in colour blocks under it, the album's songs with their play counts, and the now-playing line with the progress bar.") + screenshot("screen-foryou.svg", "screen-foryou.ansi", "trill's For You: fifty songs picked from what you play, each with a Why column saying where it came from, such as the radio of a song you play or an artist like one you play.") diff --git a/assets/readme/numbers.svg b/assets/readme/numbers.svg new file mode 100644 index 0000000..4e17faf --- /dev/null +++ b/assets/readme/numbers.svg @@ -0,0 +1,41 @@ + + + + + + + +footprint + +measured · PSS · i9-14900HX +trill +at start + +17.4 MB +trill +playing, 3,953 liked songs + +20.6 MB +trill +with For You open + +20.2 MB +Soloist +Spotify's player, playing + +~49 MB + +0% +CPU idle and paused +0.2% +CPU playing +~50 ms +launch to library +7 ms +reopen For You + diff --git a/assets/readme/screen-foryou.svg b/assets/readme/screen-foryou.svg new file mode 100644 index 0000000..00ecf45 --- /dev/null +++ b/assets/readme/screen-foryou.svg @@ -0,0 +1,1462 @@ + + + + + + + + + + + +trill +_ +_ +_ +_ +_ +_ +_ + + ✦ For You + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/ +/ +_ +_ +_ +_ +_ +_ +( +_ +) +/ +/ + +Title Artist Album Why Time + + +/ +_ +_ +/ +_ +_ +_ +/ +/ +/ +/ + +Maneater Daryl Hall & John Oa H2O radio · Valerie 4:33 + +/ +/ +_ +/ +/ +/ +/ +/ +/ + +The Sweet Escape Gwen Stefani, Akon The Sweet Escape +radio · Uptown Funk + 4:06 + +\ +_ +_ +/ +_ +/ +/ +_ +/ +_ +/ +_ +/ + +Grease - 2007 Remaster Frankie Valli Frankie Valli...Is T +radio · Le Freak + 3:27 + + + Library + + + + + + + + + + + + + + + + + + + + + + + +More Than A Woman - From "S Bee Gees Greatest +radio · Girls Just Want to H + 3:17 + + +♥ Liked Songs + + +Pocketful of Sunshine Natasha Bedingfield Pocketful Of Sunshin +radio · Valerie + 3:22 + + +◉ Albums + + +This Love Maroon 5 Songs About Jane: 10 +radio · Uptown Funk + 3:26 + + +◈ Artists + + +Caribbean Queen (No More Lo Billy Ocean The Very Best of Bil +radio · Le Freak + 4:04 + + + +✦ For You + + +Baby, I Love Your Way Big Mountain Unity +radio · Girls Just Want to H + 4:09 + + +≡ Queue + + +Get Lucky (feat. Pharrell W Daft Punk, Pharrell Random Access Memori +like Mark Ronson + 6:09 + + +⌕ Search + + +I'm Still Standing Elton John Too Low For Zero +like Queen + 3:03 + + +Morning coffee + + +Sweet Dreams (Are Made of T Eurythmics, Annie Le Sweet Dreams [(Are M +radio · Girls Just Want to H + 3:37 + + +Road trip + + +Dancing in the Moonlight Toploader Onka's Big Moka +radio · Uptown Funk + 3:52 + + +Focus + + +Crazy Gnarls Barkley, CeeL St. Elsewhere +radio · Valerie + 2:57 + + +Sunday + + +Little Lies - 2017 Remaster Fleetwood Mac Tango In the Night ( +radio · Girls Just Want to H + 3:41 + + +Running + + +Boogie Wonderland (with The Earth, Wind & Fire, I Am +radio · Le Freak + 4:48 + + +Rainy day + + +Sweet Child O' Mine Guns N' Roses Appetite For Destruc +like Queen + 5:56 + + +Throwbacks + + +Happy - From "Despicable Me Pharrell Williams G I R L +like Mark Ronson + 3:53 + + +Dinner party + + +Pump It Black Eyed Peas Monkey Business +radio · Uptown Funk + 3:33 + + +Chill + + +Back To Black Amy Winehouse Back To Black +radio · Valerie + 4:00 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Forget Me Nots - Remastered Patrice Rushen Straight from the He +radio · Le Freak + 4:44 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Could You Be Loved Bob Marley & The Wai Uprising +radio · Girls Just Want to H + 3:57 + + + + + + + + +Every Breath You Take The Police Synchronicity (Remas +like Queen + 4:13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Treasure Bruno Mars Unorthodox Jukebox +radio · Uptown Funk + 2:58 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +You Make My Dreams (Come Tr Daryl Hall & John Oa Voices +radio · Valerie + 3:10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +UNFORGIVEN (feat. Nile Rodg LE SSERAFIM, Nile Ro UNFORGIVEN +like Mark Ronson + 3:02 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Good Times CHIC Risqué +radio · Le Freak + 8:15 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Dream On Aerosmith Aerosmith +like Queen + 4:27 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Hold the Line TOTO Toto +radio · Girls Just Want to H + 3:55 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Last Train to London Rikas Last Train to London +radio · Valerie + 2:59 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Love You Like A Love Song Selena Gomez & The S When The Sun Goes Do +radio · Uptown Funk + 3:08 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Give Me the Night George Benson Give Me the Night +radio · Le Freak + 5:01 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Talk to Me (feat. Tyla, Nil Damiano David, Tyla, FUNNY little FEARS ( +like Mark Ronson + 3:13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +If You Don't Want My Love Jalen Ngonda Come Around and Love +radio · Valerie + 2:26 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Adventure of a Lifetime Coldplay A Head Full of Dream +radio · Uptown Funk + 4:23 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Livin' On A Prayer Bon Jovi Slippery When Wet (D +like Queen + 4:10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Part-Time Lover Stevie Wonder In Square Circle +radio · Le Freak + 4:12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Dancing Queen +ABBA +xfade 5s vol 65% + ⇄✦ ↻ + ⊘ + + 0:00 + 3:50 + For You: 50 songs from what you play, worked out here. X: not interested · R: new picks + diff --git a/assets/readme/screen-library.svg b/assets/readme/screen-library.svg new file mode 100644 index 0000000..e9eb662 --- /dev/null +++ b/assets/readme/screen-library.svg @@ -0,0 +1,1115 @@ + + + + + + + + + + + +trill +_ +_ +_ +_ +_ +_ +_ + + Rumours — Fleetwood Mac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/ +/ +_ +_ +_ +_ +_ +_ +( +_ +) +/ +/ + +Title Plays Time + +/ +_ +_ +/ +_ +_ +_ +/ +/ +/ +/ + +Second Hand News - 2004 Remaster + · Fleetwood Mac + 168,431,351 + 2:56 + + +/ +/ +_ +/ +/ +/ +/ +/ +/ + +Dreams - 2004 Remaster + · Fleetwood Mac +3,041,425,117 + 4:17 + +\ +_ +_ +/ +_ +/ +/ +_ +/ +_ +/ +_ +/ + +Never Going Back Again - 2004 Remaster + · Fleetwood Mac + 443,426,966 + 2:14 + + + Library + + + + + + + + + + + + + + + + + + + + + + + +Don't Stop - 2004 Remaster + · Fleetwood Mac + 593,022,262 + 3:13 + + + +♥ Liked Songs + + +Go Your Own Way - 2004 Remaster + · Fleetwood Mac +1,502,443,795 + 3:43 + + +◉ Albums + + +Songbird - 2004 Remaster + · Fleetwood Mac + 180,155,567 + 3:20 + + +◈ Artists + + +The Chain - 2004 Remaster + · Fleetwood Mac +1,959,825,540 + 4:29 + + +✦ For You + + +You Make Loving Fun - 2004 Remaster + · Fleetwood Mac + 356,964,934 + 3:33 + + +≡ Queue + + +I Don't Want to Know - 2004 Remaster + · Fleetwood Mac + 135,904,069 + 3:16 + + +⌕ Search + + +Oh Daddy - 2004 Remaster + · Fleetwood Mac + 53,624,601 + 3:56 + + +Morning coffee + + +Gold Dust Woman - 2004 Remaster + · Fleetwood Mac + 193,999,191 + 4:55 + + +Road trip + + + + +Focus + + + + +Sunday + + + + +Running + + + + +Rainy day + + + + +Throwbacks + + + + +Dinner party + + + + +Chill + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Dreams - 2004 Remaster +Fleetwood Mac +xfade 5s vol 65% + ⇄✦ ↻ + ⊘ + + 0:00 + 4:17 + Rumours — Fleetwood Mac: 11 tracks + diff --git a/assets/readme/screens/capture.sh b/assets/readme/screens/capture.sh new file mode 100755 index 0000000..4de55d6 --- /dev/null +++ b/assets/readme/screens/capture.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# Captures screens/*.ansi from the real trill in tmux at 140×42, for make.py. +# +# TRILL=target/release/trill HOMES=/path/to/copies assets/readme/screens/capture.sh +# +# HOMES holds copies of config/, cache/ and data/ (each with a trill/ inside, logged in), used as +# XDG_CONFIG_HOME, XDG_CACHE_HOME and XDG_DATA_HOME. Use copies: this writes a play log there. +# trill runs with --preview: it shows a song as playing without playing it or starting Soloist. +# For You is worked out from a short play log of well-known songs written below. The sidebar's +# playlist names are then replaced, by position, with neutral ones. +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +: "${TRILL:?path to a trill binary}" "${HOMES:?folder with config/, cache/ and data/ copies}" +TRILL=$(realpath "$TRILL") +sock=trill-readme +# the default green theme, like the other README graphics +sed -i 's/^theme=.*/theme=spotify/' "$HOMES/data/trill/audio_settings" + +run() { # run : start trill in a fresh tmux server + tmux -L $sock kill-server 2>/dev/null || true + tmux -L $sock new-session -d -x 140 -y 42 -e XDG_CONFIG_HOME="$HOMES/config" -e XDG_CACHE_HOME="$HOMES/cache" \ + -e XDG_DATA_HOME="$HOMES/data" -e TRILL_LOG= "$TRILL" --preview "$@" +} +wait_for() { # wait_for : until the pane shows it (30 s at most) + for _ in $(seq 300); do tmux -L $sock capture-pane -p | grep -q "$1" && return; sleep 0.1; done + echo "timed out waiting for: $1" >&2; exit 1 +} +grab() { sleep 1.5; tmux -L $sock capture-pane -ep > "$here/$1"; } + +# 1. playing Dreams from Rumours +run spotify:track:5TDZyWDfbQFQJabbPwImVY spotify:album:1bt6q2SruMsBtcerNVtpZB "Rumours — Fleetwood Mac" +wait_for "Gold Dust Woman" +tmux -L $sock send-keys Tab j +grab screen-library.ansi + +# 2. For You, from a play log of 16 well-known songs, 3 plays each an hour apart, last week +# (15 songs or more, so it doesn't borrow from the account's liked songs) +now=$(date +%s) +: > "$HOMES/data/trill/plays" +i=0 +while IFS='|' read -r uri title artist; do + for _ in 1 2 3; do printf '%s\tspotify:track:%s\t%s\t%s\n' $((now - 7 * 86400 + i * 3600)) "$uri" "$title" "$artist" >> "$HOMES/data/trill/plays"; i=$((i + 1)); done +done <<'SONGS' +0GjEhVFGZW8afUYGChu3Rr|Dancing Queen|ABBA +2grjqo0Frpf2okIBiifQKs|September|Earth, Wind & Fire +0DiWol3AO6WpXZgp0goxAV|One More Time|Daft Punk +6dGnYIeXmHdcikdzNNDMm2|Here Comes The Sun|The Beatles +1NHWG8zxSEypSRF3UufrnO|Don't Stop Me Now|Queen +2WfaOiMkCvy7F5fcp2zZ8L|Take on Me|a-ha +4N0TP4Rmj6QQezWV88ARNJ|Superstition|Stevie Wonder +5TDZyWDfbQFQJabbPwImVY|Dreams|Fleetwood Mac +2JiDi0qAXsPwhPqA2qaKGt|Bohemian Rhapsody|Queen +7J1uxwnxfQLu4APicE5Rnj|Billie Jean|Michael Jackson +2374M0fQpWi3dLnB54qaLX|Africa|TOTO +2RlgNHKcydI9sayD2Df2xp|Mr. Blue Sky|Electric Light Orchestra +4y1LsJpmMti1PfRQV9AWWe|Girls Just Want to Have Fun|Cyndi Lauper +4qL9VYPB4XwJKAOq4xn2Mh|Le Freak|CHIC +32OlwWuMpZ6b0aN2RZOeMS|Uptown Funk|Mark Ronson, Bruno Mars +6kopmMZiyLmw7h66uXcXR7|Valerie|Mark Ronson, Amy Winehouse +SONGS +# Spotify's radio changes over time: check the capture, and mark anything unsuitable for a README +# "not interested" here (what X does in the app). +printf '%s\n' spotify:track:5D5Iwi9xI64mqdQOU9lTui >> "$HOMES/data/trill/not_interested" +rm -f "$HOMES/cache/trill/lists/trill_foryou" # worked out afresh from that log +run spotify:track:0GjEhVFGZW8afUYGChu3Rr +wait_for "Liked Songs" +sleep 2 +tmux -L $sock send-keys g j j j Enter +wait_for "For You: [0-9]" +grab screen-foryou.ansi +tmux -L $sock send-keys q +sleep 1 +tmux -L $sock kill-server 2>/dev/null || true + +# 3. neutral playlist names in the sidebar (the rows after Search, by position) +python3 - "$here"/screen-*.ansi <<'EOF' +import re, sys +NAMES = ["Morning coffee", "Road trip", "Focus", "Sunday", "Running", "Rainy day", "Throwbacks", "Dinner party", + "Chill", "Old favourites", "Summer", "Late night", "Workout", "Acoustic", "Weekend", "Piano", "Jazz", "Indie"] +ESC = re.compile(r"\x1b\[[0-9;]*m") +def cells(line): # [(escapes before it, char)] + out, pre, i = [], "", 0 + while i < len(line): + m = ESC.match(line, i) + if m: + pre += m.group(); i = m.end(); continue + out.append((pre, line[i])); pre = ""; i += 1 + return out, pre +for path in sys.argv[1:]: + lines = open(path, encoding="utf-8").read().split("\n") + after = next(i for i, l in enumerate(lines) if "⌕ Search" in l) + 1 + n = 0 + for r in range(after, len(lines)): + cs, tail = cells(lines[r]) + if len(cs) < 32 or cs[0][1] != "│" or cs[31][1] != "│": + break # the end of the Library pane + text = "".join(c for _, c in cs[1:31]).strip() + if not text: + continue + name = NAMES[n % len(NAMES)][:30].ljust(30); n += 1 + border = cs[0][0] # the pane border's style, for the right edge too + lines[r] = border + "│\x1b[0m" + name + border + "".join(p + c for p, c in cs[31:]) + tail + open(path, "w", encoding="utf-8").write("\n".join(lines)) +EOF +echo "captured: $(ls "$here"/*.ansi | xargs -n1 basename | tr '\n' ' ')" diff --git a/assets/readme/screens/screen-foryou.ansi b/assets/readme/screens/screen-foryou.ansi new file mode 100644 index 0000000..d9361e3 --- /dev/null +++ b/assets/readme/screens/screen-foryou.ansi @@ -0,0 +1,42 @@ +    __       _ ____ ╭ ✦ For You ───────────────────────────────────────────────────────────────────────────────────────────────╮ +   / /______(_) / / │Title Artist Album Why Time│ +  / __/ ___/ / / /  │Maneater Daryl Hall & John Oa H2O radio · Valerie 4:33│ + / /_/ /  / / / /   │The Sweet Escape Gwen Stefani, Akon The Sweet Escape radio · Uptown Funk  4:06│ + \__/_/  /_/_/_/    │Grease - 2007 Remaster Frankie Valli Frankie Valli...Is T radio · Le Freak  3:27│ +╭ Library ─────────────────────╮│More Than A Woman - From "S Bee Gees Greatest radio · Girls Just Want to H 3:17│ +│♥ Liked Songs ││Pocketful of Sunshine Natasha Bedingfield Pocketful Of Sunshin radio · Valerie  3:22│ +│◉ Albums ││This Love Maroon 5 Songs About Jane: 10 radio · Uptown Funk  3:26│ +│◈ Artists ││Caribbean Queen (No More Lo Billy Ocean The Very Best of Bil radio · Le Freak  4:04│ +│✦ For You ││Baby, I Love Your Way Big Mountain Unity radio · Girls Just Want to H 4:09│ +│≡ Queue ││Get Lucky (feat. Pharrell W Daft Punk, Pharrell Random Access Memori like Mark Ronson  6:09│ +│⌕ Search ││I'm Still Standing Elton John Too Low For Zero like Queen  3:03│ +│Morning coffee ││Sweet Dreams (Are Made of T Eurythmics, Annie Le Sweet Dreams [(Are M radio · Girls Just Want to H 3:37│ +│Road trip ││Dancing in the Moonlight Toploader Onka's Big Moka radio · Uptown Funk  3:52│ +│Focus ││Crazy Gnarls Barkley, CeeL St. Elsewhere radio · Valerie  2:57│ +│Sunday ││Little Lies - 2017 Remaster Fleetwood Mac Tango In the Night ( radio · Girls Just Want to H 3:41│ +│Running ││Boogie Wonderland (with The Earth, Wind & Fire, I Am radio · Le Freak  4:48│ +│Rainy day ││Sweet Child O' Mine Guns N' Roses Appetite For Destruc like Queen  5:56│ +│Throwbacks ││Happy - From "Despicable Me Pharrell Williams G I R L like Mark Ronson  3:53│ +│Dinner party ││Pump It Black Eyed Peas Monkey Business radio · Uptown Funk  3:33│ +│Chill ││Back To Black Amy Winehouse Back To Black radio · Valerie  4:00│ +╰──────────────────────────────╯│Forget Me Nots - Remastered Patrice Rushen Straight from the He radio · Le Freak  4:44│ +╭──────────────────────────────╮│Could You Be Loved Bob Marley & The Wai Uprising radio · Girls Just Want to H 3:57│ +│ ▄▄ ▄││Every Breath You Take The Police Synchronicity (Remas like Queen  4:13│ +│▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄││Treasure Bruno Mars Unorthodox Jukebox radio · Uptown Funk  2:58│ +│▄▄▄▄▄▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄▄▄▄▄▄││You Make My Dreams (Come Tr Daryl Hall & John Oa Voices radio · Valerie  3:10│ +│▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄││UNFORGIVEN (feat. Nile Rodg LE SSERAFIM, Nile Ro UNFORGIVEN like Mark Ronson  3:02│ +│▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄││Good Times CHIC Risqué radio · Le Freak  8:15│ +│▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄││Dream On Aerosmith Aerosmith like Queen  4:27│ +│▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▀▀▄▄▄▄▄▄▄▄▄▄▄▄││Hold the Line TOTO Toto radio · Girls Just Want to H 3:55│ +│▄▄▄▄▄▄▄▄▄▀▀▄▄▄▄▄▄▄▄▄▀▄▄▄▄▄▄▄▄▄││Last Train to London Rikas Last Train to London radio · Valerie  2:59│ +│▄▄▄▄▄▄▄▀▀▄▄▀▀▀▀▀▀▄▄▀▄▄▀▄▄▄▄▄▄▄││Love You Like A Love Song Selena Gomez & The S When The Sun Goes Do radio · Uptown Funk  3:08│ +│▄▄▄▄▄▄▀▄▀▀▀▀▀▄▀▄▄▀▀▀▀▀▀▀▄▄▄▄▄▄││Give Me the Night George Benson Give Me the Night radio · Le Freak  5:01│ +│▄▄▄▄▄▀▀▀▄▄▄▄▄▄▄▄▄▀▀▄▄▄▄▀▀▀▀▀▀▀││Talk to Me (feat. Tyla, Nil Damiano David, Tyla, FUNNY little FEARS ( like Mark Ronson  3:13│ +│▀▀▀▀▀▀▄▀▄▄▄▄▀▀▄▀▀▄▄▀▀▀▀▄▀▀▀▀▀▀││If You Don't Want My Love Jalen Ngonda Come Around and Love radio · Valerie  2:26│ +│▀▀▀▀▀▀▀▀▀▀▀▄▀▀▀▀▀▀▀▀▀▄▀▀▀▀▀▀▀▀││Adventure of a Lifetime Coldplay A Head Full of Dream radio · Uptown Funk  4:23│ +│▀▀▀▀▀▀▄▀▀▀▀▀▄▄▀▀▀▀▀▀▀▀▄▀▀▀▀▀▀▀││Livin' On A Prayer Bon Jovi Slippery When Wet (D like Queen  4:10│ +│▀▀▀▄▄▀▀▀▄▀▀▀▀▀▀▄▀▄▄▄▄▄▄▄▀▀▀▀▀▀││Part-Time Lover Stevie Wonder In Square Circle radio · Le Freak  4:12│ +╰──────────────────────────────╯╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + ⏸ Dancing Queen ABBA xfade 5s vol 65%  ⇄✦ ↻  ⊘ + 0:00   3:50 + For You: 50 songs from what you play, worked out here. X: not interested · R: new picks diff --git a/assets/readme/screens/screen-library.ansi b/assets/readme/screens/screen-library.ansi new file mode 100644 index 0000000..649be80 --- /dev/null +++ b/assets/readme/screens/screen-library.ansi @@ -0,0 +1,42 @@ +    __       _ ____ ╭ Rumours — Fleetwood Mac ─────────────────────────────────────────────────────────────────────────────────╮ +   / /______(_) / / │Title Plays Time│ +  / __/ ___/ / / /  │Second Hand News - 2004 Remaster · Fleetwood Mac  168,431,351 2:56│ + / /_/ /  / / / /   │Dreams - 2004 Remaster · Fleetwood Mac 3,041,425,117 4:17│ + \__/_/  /_/_/_/    │Never Going Back Again - 2004 Remaster · Fleetwood Mac  443,426,966 2:14│ +╭ Library ─────────────────────╮│Don't Stop - 2004 Remaster · Fleetwood Mac  593,022,262 3:13│ +│♥ Liked Songs ││Go Your Own Way - 2004 Remaster · Fleetwood Mac 1,502,443,795 3:43│ +│◉ Albums ││Songbird - 2004 Remaster · Fleetwood Mac  180,155,567 3:20│ +│◈ Artists ││The Chain - 2004 Remaster · Fleetwood Mac 1,959,825,540 4:29│ +│✦ For You ││You Make Loving Fun - 2004 Remaster · Fleetwood Mac  356,964,934 3:33│ +│≡ Queue ││I Don't Want to Know - 2004 Remaster · Fleetwood Mac  135,904,069 3:16│ +│⌕ Search ││Oh Daddy - 2004 Remaster · Fleetwood Mac  53,624,601 3:56│ +│Morning coffee ││Gold Dust Woman - 2004 Remaster · Fleetwood Mac  193,999,191 4:55│ +│Road trip ││ │ +│Focus ││ │ +│Sunday ││ │ +│Running ││ │ +│Rainy day ││ │ +│Throwbacks ││ │ +│Dinner party ││ │ +│Chill ││ │ +╰──────────────────────────────╯│ │ +╭──────────────────────────────╮│ │ +│ ▀▀▀ ▀ ││ │ +│ ▀▀▀▀▀▀▄▄▄▄▀▀▀▀▀▀▀▀▄▀ ││ │ +│ ▄▄▄▀▀▀▄▄▄▄▄▄▀▀▄▀▄▄▄▄▄ ││ │ +│ ▀▀▀▀▀▄▀▀▀ ▀▀▀▄▄▄▄▄▄ ││ │ +│ ▀▀▄▄▄▀▀▀▀▀▀▀▀▄▀▀ ││ │ +│  ▀▀ ▄▄▀▄▄▄▀▀▄▀▀▀▀▀▀▀▀ ││ │ +│ ▄▄▀▀▄▄▀▀▀▄▄ ▄▄▀▄▄▄▄▀▀ ││ │ +│ ▄▄▀▀▄▄▀▀▀▀▀▀▀▀▀▄▄▄▄▀▀ ││ │ +│ ▄▄▀▄▄▄▄▀▀▀▄▄▀▀▀▀▀▄▄▄ ││ │ +│ ▄▄▀ ▄▄▄▄▄▀▄▀▄▀▄▄▄▄ ││ │ +│ ▄▄▀▀▀▀▀▄▄▄▄▀▄▄▀ ││ │ +│ ▄▄▄▄▀▄▄▄▄▄▄▄▀▀▄ ││ │ +│ ▄▄▄ ▄▀▀▀▀▄▄▄▄▄▄ ││ │ +│ ▄▀▀ ▀▄▄▀▀▄▄▄▄ ││ │ +│ ▄▄▄ ▄▄▄▄▄▄▄▄ ││ │ +╰──────────────────────────────╯╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + ⏸ Dreams - 2004 Remaster Fleetwood Mac xfade 5s vol 65%  ⇄✦ ↻  ⊘ + 0:00   4:17 + Rumours — Fleetwood Mac: 11 tracks diff --git a/assets/readme/speed.svg b/assets/readme/speed.svg deleted file mode 100644 index 70b646a..0000000 --- a/assets/readme/speed.svg +++ /dev/null @@ -1,322 +0,0 @@ - - - - - - -speed - -i9-14900HX · ~150 ms to Spotify · log scale -Key press to redraw - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -2 ms -Reopen 3,901 liked songs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -2 ms -Launch to library - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -30 ms -Press play to playing - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.2 s -Search - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.35 s -First open, 3,901 songs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.45–0.7 s - -1 ms - -10 ms - -100 ms - -1 s -