Spotify has a good Linux client. But it doesn’t support MPD, so it is problematic to interact with Spotify using shortcuts or create a blocklet in i3 statusbar. Here I’d like to show how it could be achieved. At end we’ll have following blocklet:


Spotify CLI

First of all let’s see how we can control Spotify from the command line. Luckily Spotify app supports MPRIS2 DBus specification, which basically means that you can send dbus messages to Spotify with actions, like play/pause, next, etc. To simplify this process here is the bash script which wraps it in handy functions:

Let’s install it:

git clone
cd ./fa6258f3ff7b17747ee3
chmod +x
sudo ln -s ./sp /usr/local/bin/

Test it by running sp help.

i3 shortcuts

With sp installed it’s pretty simple to create keyboard shortcut, I’m using following combinations:

  • mod+. - next track
  • mod+, - previous
  • mod+/ - play/pause

Add following snipped to your i3 config:


bindsym $mod+greater exec "sp next"
bindsym $mod+less exec "sp prev"
bindsym $mod+slash exec "sp play"

i3 blocklet

Here is also nothing special. sp has two methods which is used in this blocklet - sp current-oneline to get the current artist and song name and sp status which tells if music is currently playing or not. This blocklet also supports mouse controls. Please note that you will need to install Font Awesome to have a play/pause icon.

Create spotify_blocklet file under ~/.config/i3/ with following content:



    1) sp play ;; # left click
    4) sp next ;; # scroll up
    5) sp prev ;; # scroll down

if sp status | grep 'Paused' > /dev/null; then
    printf '\xef\x81\x8c ' # fa-pause
    printf '\xef\x81\x8b ' # fa-play
sp current-oneline

Make it executable (chmod +x ./spotify_blocklet) and test it by executing. Finally in .i3blocks.conf add blocklet definition: