-
-
Save eggman64/555aef628dc6d370cb1b283346536e75 to your computer and use it in GitHub Desktop.
Adds now playing indicator from spotify or MPD to i3status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
i3status | while : | |
do | |
read line | |
dir=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) | |
spotify_status=$(dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus' | tail -n1 | cut -d'"' -f2) | |
spotify_artist=$(dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' | awk -f ${dir}/spotify_song.awk | head -n 1 | cut -d':' -f2) | |
spotify_song=$(dbus-send --print-reply --session --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' | awk -f ${dir}/spotify_song.awk | tail -n 1 | cut -d':' -f2) | |
mpd_song=$(mpc current) | |
if [ "$spotify_status" = "Playing" ] ; then | |
echo -n "NP: $spotify_artist - $spotify_song | $line" || exit 1 | |
continue | |
elif [ "$mpd_song" != "" ]; then | |
mpd_status=$(mpc status | tail -2 | head -1 | cut -d' ' -f1 | tr -d '[]') | |
if [ "$mpd_status" = "playing" ]; then | |
echo -n "NP: $mpd_song | $line" || exit 1 | |
continue | |
fi | |
echo -n $line || exit 1 | |
continue | |
fi | |
echo -n $line || exit 1 | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/string *"xesam:artist/{ | |
while (1) { | |
getline line | |
if (line ~ /string "/) { | |
sub(/.*string "/, "artist:", line) | |
sub(/".*$/, "", line) | |
print line | |
break | |
} | |
} | |
} | |
/string *"xesam:title/{ | |
while(1) { | |
getline line | |
if (line ~ /string "/) { | |
sub(/.*string "/, "title:", line) | |
sub(/".*$/, "", line) | |
print line | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment