doti3/bar/src/spotify_ctrl.php

29 lines
574 B
PHP
Raw Normal View History

2019-01-21 16:20:04 +01:00
#!/usr/bin/php
<?php
require __DIR__.'/base/block.php';
$status = trim(shell_exec('playerctl -p spotify status'));
if ($status === 'Playing') {
$fullText = '▮▮';
} elseif ($status === 'Paused') {
$fullText = '▶';
}
if (empty($fullText)) {
die(0);
}
if (getenv('BLOCK_BUTTON') === '1') {
shell_exec('dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause');
}
echo block(
'spotify_ctrl',
[
'full_text' => $fullText,
'color' => color('music'),
]
);