commit 2cf8bfa94c7523792f4c55bd56c6072b6ffd0fdc Author: haskal Date: Mon Nov 18 21:17:14 2019 -0500 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..df8314a --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# GNOME Now Playing # + +This script uses [Argos](https://github.com/p-e-w/argos) to display a Now Playing panel that fetches +the current song artist and title using MPRIS (D-Bus). + +To install, put the script in `~/.config/argos/` diff --git a/np.10s.sh b/np.10s.sh new file mode 100755 index 0000000..3ca8f17 --- /dev/null +++ b/np.10s.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +MPRIS_ROOT='org.mpris.MediaPlayer2.*' +MPRIS_PATH='/org/mpris/MediaPlayer2' +DBUS_GET='org.freedesktop.DBus.Properties.Get' +MPRIS_PLAYER='org.mpris.MediaPlayer2.Player' +XESAM_ARTIST="xesam:albumArtist: " +XESAM_ARTIST2="xesam:artist: " +XESAM_TITLE="xesam:title: " + +for player in $(qdbus $MPRIS_ROOT); do + state=$(qdbus "$player" $MPRIS_PATH $DBUS_GET $MPRIS_PLAYER PlaybackStatus) + if [ "$state" == "Playing" ]; then + metadata=$(qdbus "$player" $MPRIS_PATH $DBUS_GET $MPRIS_PLAYER Metadata) + artist=$(echo "$metadata" | grep "$XESAM_ARTIST") + artist=${artist#"$XESAM_ARTIST"} + artist2=$(echo "$metadata" | grep "$XESAM_ARTIST2") + artist2=${artist2#"$XESAM_ARTIST2"} + title=$(echo "$metadata" | grep "$XESAM_TITLE") + title=${title#"$XESAM_TITLE"} + if [ "$title" != "" ]; then + if [ "$artist" == "" ]; then + if [ "$artist2" == "" ]; then + echo "$title | iconName=multimedia-audio-player-symbolic" + else + echo "$artist2 - $title | iconName=multimedia-audio-player-symbolic" + fi + else + echo "$artist - $title | iconName=multimedia-audio-player-symbolic" + fi + echo "---" + exit + fi + fi +done + +echo "---"