Coder Social home page Coder Social logo

polybar-spotify's Introduction

polybar-spotify

This polybar module shows details regarding the currently playing song on Spotify. The unique feature of this module is that the text displayed is constantly scrolled to save space on the bar. This is something that is not found in other spotify modules I came across. Also, this module uses playerctl to do all the work and hence, no >100 line scripts which do all the work themselves. Only one line to fetch the required metadata in the format that you like and another line to scroll the fetched text using zscroll.

Dependencies

  • playerctl - To interface with Spotify and other MPRIS supporting players
  • zscroll - To scroll the fetched text

Setup

  • Make sure to go through and edit the required variables in get_spotify_status.sh as shown below. Especially the PARENT_BAR one as without its correct value, toggling the play-pause symbol wouldn't work.
# The name of polybar bar which houses the main spotify module and the control modules.
PARENT_BAR="now-playing"

# Set the source audio player here.
# Players supporting the MPRIS spec are supported.
# Examples: spotify, vlc, chrome, mpv and others.
# Use `playerctld` to detect the latest player.
# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control
PLAYER="playerctld"

# Format of the information displayed
# Eg. {{ artist }} - {{ album }} - {{ title }}
# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata
FORMAT="{{ title }} - {{ artist }}"
  • Add the following in your polybar config. Make sure to place the desired symbols for each module. You can get them from like Font Awesome or Nerd Fonts.
[module/spotify]
type = custom/script
tail = true
interval = 1
; prefix symbol is shown before the text
format-prefix = "<prefix-symbol>"
format = <label>
exec = ~/.config/polybar/scripts/scroll_spotify_status.sh

[module/spotify-prev]
type = custom/script
exec = echo "<previous-song-symbol>"
format = <label>
click-left = playerctl previous -p spotify

[module/spotify-play-pause]
type = custom/ipc
hook-0 = echo "<playing-symbol>"
hook-1 = echo "<pause-symbol>"
initial = 1
click-left = playerctl play-pause -p spotify

[module/spotify-next]
type = custom/script
exec = echo "next-song-symbol"
format = <label>
click-left = playerctl next -p spotify

NOTE: The above given play-pause module requires IPC support enabled for its parent bar. That can be done by adding enable-ipc = true in your bar config.

Support for KDE panel

To have this bar show up in your KDE panel, see #21.

Customization

  • Since I'm using playerctl, this script will work with any of the players supported by it. For instance, VLC, Chromium, Audacious, etc. It can even be used with multiple players running simultaneously. More info here.
  • The format of the fetched metadata can be changed in get_spotify_status.sh. This line needs to be changed
    playerctl metadata spotify --format "{{ title }} - {{ artist }}"
    More details on what attributes can be fetched can be found here.
  • The scrolling text can be configured in scroll_spotify_status.sh.
    • The length can be configured using -l and delay using -d.
    • The separators between the infinitely scrolling text can be configured using --before-text and --after-text parameters.
      More info about zscroll's parameters can be found in man zscroll.

polybar-spotify's People

Contributors

prayags avatar amirhossein-ka avatar imgbotapp avatar kivalm avatar p0ryae avatar rlipperts avatar seitahigashi 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.