Skip to content

Commit c63b2ef

Browse files
committed
✨ Playback status is now queried via dbus-send.
1 parent 0f8bbad commit c63b2ef

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

segments/now_playing.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ __np_spotify() {
291291
else
292292
metadata=$(dbus-send --reply-timeout=42 --print-reply --session --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' 2>/dev/null)
293293
if [ "$?" -eq 0 ] && [ -n "$metadata" ]; then
294-
# TODO how do one express this with dbus-send? It works with qdbus but the problem is that it's probably not as common as dbus-send.
295-
state=$(qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus)
294+
state=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$)
296295
if [[ $state == "Playing" ]]; then
297296
artist=$(echo "$metadata" | grep -PA2 "string\s\"xesam:artist\"" | tail -1 | grep -Po "(?<=\").*(?=\")")
298297
track=$(echo "$metadata" | grep -PA1 "string\s\"xesam:title\"" | tail -1 | grep -Po "(?<=\").*(?=\")")

0 commit comments

Comments
 (0)