37 lines
725 B
PHP
37 lines
725 B
PHP
|
#!/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)
|
|||
|
{
|
|||
|
$string = trim(str_replace(['"', "'"], ' ', $d));
|
|||
|
|
|||
|
if (mb_strlen($string) > 15) {
|
|||
|
$string = substr($string, 0, 15).'…';
|
|||
|
}
|
|||
|
|
|||
|
return $string;
|
|||
|
}
|
|||
|
|
|||
|
$title = cleanUp(shell_exec('playerctl -p spotify metadata xesam:title'));
|
|||
|
$artist = cleanUp(shell_exec('playerctl -p spotify metadata xesam:artist'));
|
|||
|
|
|||
|
$label = sprintf('%s – %s', $title, $artist);
|
|||
|
|
|||
|
$fullText = sprintf('%s – %s', $title, $artist);
|
|||
|
|
|||
|
echo block(
|
|||
|
'spotify',
|
|||
|
[
|
|||
|
'full_text' => $fullText,
|
|||
|
'color' => color('music'),
|
|||
|
]
|
|||
|
);
|