Sync Cava colors to Spotify album art. I made this in about 3 hours, learning all my Rust from the Rust book and ChatGPT. The script grabs the album art for the currently playing song (the mechanism for this is OS-dependent) and then uses PNGQuant to quantize the image to 3 colors. These 3 colors are then used to recolor the visualizer.
This project changes colors for the Cava Terminal visualizer. Instructions for installing Cava are available on the project's GitHub.
- Go to the
.env.template
file in this project and change it to.env
. If you're using linux you can remove all lines in this file except forCAVA_CONFIG_LOCATION
. - Find your Cava config (by default
~/.config/cava/config
) and modify theCAVA_CONFIG_LOCATION
env var to point at the config (it should just be the default). - Follow your OS-specific instructions below
- Use
cargo run
to run this program (you will need to runcava
in a separate window, and have Spotify running for anything to happen. Will not open either automatically).
Make sure you have playerctl
installed. playerctl
(repo) is a CLI tool that implements MPRIS and makes for faster and less resource-intensive polling for the album art.
Without a handy utility availble like playerctl
, installation is a little more involved. There is some AppleScripts magic that you can use to automate this on OSX, but for now
we can just auth with the Spotify client directly (even if it is a bit cumbersome). I use a Linux box, so I haven't spent too much time thinking about this flow. Might smooth this process out later.
- Grab a set of Spotify API credentials (either get them from me (Kanyes) or use your own).
- Put these API keys into your
.env
files under the appropriate environment variables - When you run the program, you will be taken to your browser and asked to authenticate with Spotify. Once you do so, copy and paste the URL you are taken to (will be an error page) and paste it back into your terminal. As of right now there's no refresh-token persistence, so you'll have to do this copy-pasting every time you restart the app.