#!/usr/bin/php
<?php

require __DIR__.'/base/block.php';

$status = trim(shell_exec('playerctl -p spotify status'));

if (!in_array($status, ['Playing'])) {
    die;
}

function cleanUp($d, $max = 20)
{
    $string = trim(str_replace(['"', "'"], ' ', $d));
    $string = str_replace('&', 'et', $string);

    if (mb_strlen($string) > $max) {
        $string = substr($string, 0, $max).'…';
    }

    return $string;
}

$title = cleanUp(shell_exec('playerctl -p spotify metadata xesam:title'));
$artist = cleanUp(shell_exec('playerctl -p spotify metadata xesam:artist'));

$fullText = pspan($artist, '#ccc', '#222').pspan($title, '#ddd', '#000');

if (getenv('BLOCK_BUTTON') === '1') {
    shell_exec('i3-msg \'workspace "6. MEDIA"\'');
}

echo block(
    'spotify',
    [
        'full_text' => $fullText,
        'color' => color('music'),
        'separator' => false,
        'separator_block_width' => 0,
    ]
);
Insérer
<div%key%id="gist-5c87a590f1cf5-59575f43d42060249b0c9bc09ebd5a0d84d1cb1f" class="gist-container"></div>
<script src="https://gist.deblan.org/fr/embedjs/5c87a590f1cf5" async></script>