Git Product home page Git Product logo

spotifatius's Introduction

Spotifatius

Spotify + status + some Latin = Spotifatius.

A simple Spotify CLI primarily made for monitoring what songs you're listening to and displaying that in your bar of choice like waybar or polybar.

Usage

First make sure the RSPOTIFY_CLIENT_ID and RSPOTIFY_CLIENT_SECRET environment variables are available in your shell environment. They need to contain the Spotify developer Client ID and secret. Follow Spotify's Developer Documentation on how to set that up, make sure the redirect URI is set to http://localhost. Once done, run spotifatius monitor once to setup Spotify access tokens:

$ spotifatius monitor
Opened https://accounts.spotify.com/authorize?[...] in your browser.
Please enter the URL you were redirected to:
[INSERT URL HERE]
{"text":"Twenty One Pilots - Bounce Man","tooltip":"Scaled And Icy","class":["playing"]}

From then on, this step will no longer be required. You can then add spotifatius monitor to your favourite bar, see Bar Integration. The first invocation of this command will start a server that is required by other commands. If there is already a server running, it will mirror the output from said server, this is useful if you want the monitoring to show on multiple displays.

To toggle the liked state anywhere, use toggle-liked.

$ spotifatius toggle-liked
Added to library!

That will update the monitoring server/client:

{"text":"Added to library!","class":["added"]}
{"text":"Twenty One Pilots + Bounce Man","tooltip":"Scaled And Icy","class":["liked","playing"]}

Doing that again will remove the liked state:

$ spotifatius toggle-liked
Removed from library!
{"text":"Removed from library!","class":["removed"]}
{"text":"Twenty One Pilots - Bounce Man","tooltip":"Scaled And Icy","class":["playing"]}

Liked songs also have a + instead of a - between the artist and song title.

Bar Integration

Here are some configuration examples for the supported bars.

Waybar

Add the following to make it available as a module:

"custom/spotify": {
    "format": "{}",
    "return-type": "json",
    "on-click-right": "spotifatius toggle-liked",
    "exec": "spotifatius monitor"
}

The following classes are supported:

  • playing: the current song is playing.
  • paused: the current song is paused.
  • stopped: the current song is stopped.
  • liked: the current song is in your liked songs.
  • added: there's a message being displayed saying the song was just added to your liked songs.
  • removed: there's a message being displayed saying the song was just removed to your liked songs.

Polybar

[module/spotify]
type = custom/script
exec = spotifatius monitor --output-type polybar
tail = true
click-right = spotifatius toggle-liked

Polybar maps the classes from the waybar output to colors that you can define in your config file ~/.config/spotifatius/config.toml:

[polybar]
[polybar.colors]
# added = ""
# liked = ""
paused = "#6E6E6E"
playing = "#CECECE"
# removed = ""

By default there are no colors set for polybar.

Some example output:

$ spotifatius monitor --output-type polybar
# Output for playing unliked song.
%{F#CECECE}Twenty One Pilots - Bounce Man%{F-}
# Output for playing liked song.
%{F#CECECE}Twenty One Pilots + Bounce Man%{F-}
# Output for paused liked song.
%{F#6E6E6E}Twenty One Pilots + Bounce Man%{F-}

Server/Client via gRPC

Spotifatius' monitor command will be default because a gRPC server that is streaming monitor updates, see proto/service.proto. If a monitor instance detects the port is already used by another monitor instance, it will start listening over gRPC so all instances are in sync. As of writing, closing the server instance will also close the client.

Installation

If you would like spotifatius to be available on your distro's package manager, feel free to make an issue if you have some time to help.

Arch User Repository (AUR)

paru -S spotifatius

Cargo (crates.io)

cargo install spotifatius --locked

Manually

git clone [email protected]:AndreasBackx/spotifatius.git
cd spotifatius
cargo install --path . --locked

Logging

Pass RUST_LOG with either trace, debug, info, warn, or error to set the logging level, default is error. See tracing-subcriber documentation for more info.

spotifatius's People

Contributors

andreasbackx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.