Skip to main content

i3blocks-spotify-persist

A persistent i3blocks blocklet for the Spotify desktop app.

screenshot

Click the image above to watch a screencast.

Features

  • near-immediate updates thanks to the event-driven model: the blocket is a constantly running process receiving D-Bus signals
  • configurable output
  • configurable mouse click actions (i3blocks version 1.5 or later is required)

Installation

Python version 3.5 or later is required.

The blocket can be installed from PyPI using pip:

python3 -m pip install [--user] i3blocks-spotify-persist

Once the package is installed, there will be a blocket script named i3blocks-spotify-persist somewhere depending on the presence of a --user pip flag (e.g., /usr/local/bin/i3blocks-spotify-persist or ~/.local/bin/i3blocks-spotify-persist).

To avoid dependecy hell, pipx can be used:

pipx install i3blocks-spotify-persist

In this case the blocket script will be placed in ~/.local/bin directory.

Dependencies

Required (installed automatically):

Optional (installed manually):

Usage

Add the following lines to your i3blocks config:

[spotify]
command=/path/to/bin/i3blocks-spotify-persist [-c /path/to/config.json]
interval=persist

Configuration

The blocket can be configured using a JSON config file. The config itself and all its options are optional.

Config options

format

Type: string

Default value: {status}: {artist} – {title}

A template string with placeholders. Placeholder formats are {field} and {field:filter}.

Supported fields:

  • status, one of enum values: Playing, Paused, Stopped
  • artist
  • title

Supported fitlers:

  • upper — converts a string to uppercase
  • lower — converts a string to lowercase
  • capitalize — converts the first character of a string to uppercase and the rest to lowercase
  • icon — for status field only: converts a textual status to an icon (see the status_icons option below)

markup_escape

Type: boolean

Default value: false

This option specifies whether to escape special characters (such as <, >, &) using corresponding XML entities. Set to true if Pango markup is used (markup=pango in your i3blocks config), false otherwise.

status_icons

Type: object

Default value: {"Playing": "\uf04b", "Paused": "\uf04c", "Stopped": "\uf04d"}

This option provides a mapping for the icon filter (see above). The default value uses icons from Font Awesome.

mouse_buttons

Type: object

Default value: {"1": "PlayPause"}

This option provides a mapping of X11 mouse buttons numbers to MPRIS methods. You can use the xev program to determine button numbers.

dedupe

Type: boolean

Default value: true

For some reason, the Spotify app emits several identical signals for one action/event (e.g., it produces four PropertiesChanged signals when a track is played or paused). If this option is set true, the blocklet will compare the updated message with the previous one and print it only if it has changed. There is no reason to turn off deduplication except for debugging.

Config example

{
    "format": "<span font_family='monospace' color='#ffa651' weight='bold'>{status:icon} {status:upper}</span> <span color='#72bf44' weight='bold'>{artist}</span><span color='#ffa651'>᛫</span><span color='#b2d235'>{title}</span>",
    "markup_escape": true,
    "status_icons": {
        "Playing": "|>",
        "Paused": "||",
        "Stopped": "[]"
    },
    "mouse_buttons": {
        "1": "PlayPause",
        "9": "Previous",
        "8": "Next"
    }
}

Command line arguments

  • -h, --help — show all command line arguments and exit
  • -c, --config — a path to the config file (see above)

The following arguments override corresponding config options or defaults (that is, command line arguments have the highest precedence):

  • --format
  • --markup-escape / --no-markup-escape
  • --dedupe / --no-dedupe

License

The MIT License.

Metadata

Release files for i3blocks-spotify-persist 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for i3blocks-spotify-persist 1.2.0
File Size Uploaded
i3blocks-spotify-persist-1.2.0.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for i3blocks-spotify-persist 1.2.0
File Interpreter ABI Platform
i3blocks_spotify_persist-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / i3blocks-spotify-persist-1.2.0.tar.gz

Download URL i3blocks-spotify-persist-1.2.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0e782b66c7b800c26563da62f77ef720ada33d6649142b544ae42941d2617a7b
BLAKE2b-256 checksum
How to use checksums
83606a172d67d5af1b1328c949ef073a534a215059d14d4c55ec6c83e14ecd8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / i3blocks_spotify_persist-1.2.0-py3-none-any.whl

Download URL i3blocks_spotify_persist-1.2.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc193f8a441f496f7ff876166c082d08c25b9c071ffcc4e79ac8f9664c6adc3d
BLAKE2b-256 checksum
How to use checksums
dcc46f5d839258d4e51b618cf13fbeb665868c227e22e75ac24f1b8d09c6a3ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page