Initial commit

This commit is contained in:
xenia 2019-11-18 21:17:14 -05:00
commit 2cf8bfa94c
2 changed files with 43 additions and 0 deletions

6
README.md Normal file
View File

@ -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/`

37
np.10s.sh Executable file
View File

@ -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 "---"