Skip to content

conor-f/spotibar

Repository files navigation

Spotibar

Polybar/Waybar plugin for Spotify that uses the Spotify Web API. Note that this requires a Spotify premium account.

Features:

  • Display currently playing artist/song
  • Play/Pause, Previous, Next functionality
  • Add to playlist
  • Scroll currently playing tracking output
  • Have other options for selecting what playlist to add to
  • Add last.fm hearting track option

Spotibar Config Menu spotibar_Closed

Usage/Experience:

After installing and configuring spotibar to run on your status bar as described below, you should see the currently playing track/artist, interactive controls to go to the previous song, play/pause and go to the next track. The thing that justifies the little bit of extra work to set up this module is in the final icon, options/playlists. If you right click on this option, you will get a config option popup which lets you enable/disable adding tracks you like to a Spotify playlist, hearting the track on last.fm, the different display options, etc. It will also allow you to select multiple playlists to add to at once, and other options. Clicking it will trigger all liking/adding to playlist options.

Installation:

Installation is in three steps, the first is getting credentials from Spotify. You need to create an app (call it whatever you like) to find your Client ID and Client Secret, and you need to Edit Settings, and set the Redirect URIs to http://127.0.0.1.

Secondly, you need to install spotibar and run it's init processes:

pipx install spotibar
spotibar --init

During this install process, you will be directed to open a browser to allow Spotibar interact with your Spotify account. After accepting this, you will be redirected to a URL beginning with http://127.0.0.1. Copy this whole URL and paste it back into the init process when asked!

If you're getting errors, try removing spotibar and reinstalling under sudo permissions. If you get an error involving libtk8.6.so, install tk using your distro's package manager.

Once spotibar is installed and authenticated, you need to modify your status bar config as follows (or however suits your needs!):

Polybar:

modules-right = <other modules> spotibar-currently-playing spotibar-previous-track spotibar-toggle-playback spotibar-next-track spotibar-add-to-playlist <other modules>

[module/spotibar-previous-track]
type = custom/script
exec = echo ""
click-left = spotibar --previous-track
exec-if = [ $(spotibar --is-live) = "True" ]
format-underline = #1db954
format-padding = 2

[module/spotibar-next-track]
type = custom/script
exec = echo ""
click-left = spotibar --next-track
exec-if = [ $(spotibar --is-live) = "True" ]
format-underline = #1db954
format-padding = 2

[module/spotibar-toggle-playback]
type = custom/script
exec = echo " "
click-left = spotibar --toggle-playback
exec-if = "pgrep spotify"
format-underline = #1db954
format-padding = 2

[module/spotibar-currently-playing]
type = custom/script
exec = spotibar --get-currently-playing
click-left = i3-msg '[class="Spotify"] focus'
exec-if = [ $(spotibar --is-live) = "True" ]
format-underline = #1db954
format-padding = 2

[module/spotibar-add-to-playlist]
type = custom/script
exec = echo "≣"
click-left = spotibar --add-track-to-monthly-playlist
click-right = spotibar --config-popup
exec-if = [ $(spotibar --is-live) = "True" ]
format-underline = #1db954
format-padding = 2

Waybar:

Note that this relies on mediaplayer.py to output the currently playing track. This behaviour can easily be modified (e.g. by using spotibar --get-currently-playing)

"modules-center": ["custom/media", "custom/media-skip-backward", "custom/media-play-pause", "custom/media-skip-forward"],

"custom/media": {
  "format": "{icon}   {}",
  "return-type": "json",
  "max-length": 40,
  "format-icons": {
    "spotify": "",
    "default": "🎜"
  },
  "escape": true,
  "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null",
  "on-click-right": "spotibar --add-track-to-monthly-playlist"
},

"custom/media-play-pause": {
  "format": "<span size='20pt'>\udb81\udc0e</span>",
  "on-click": "playerctl play-pause",
},
"custom/media-skip-backward": {
  "format": "<span size='20pt'>\udb81\udcab</span>",
  "on-click": "playerctl previous",
},
"custom/media-skip-forward": {
  "format": "<span size='20pt'>\udb81\udcac</span>",
  "on-click": "playerctl next",
},

You should also modify your ~/.config/waybar/styles.css to style the buttons added above. e.g.

#custom-media-skip-backward,
#custom-media-play-pause,
#custom-media-skip-forward {
    padding: 0 6px;
    color: #ffffff;
}

Done! Enjoy! File (probably inevitable) bug reports as issues!

Development:

Create an issue if you have any bug reports/feature requests/want to add a feature and are looking for help with the environment setup.

About

Polybar plugin for Spotify

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published