-
-
Save Romern/8cb31ae62b3f8e5dedb90c2c739dac70 to your computer and use it in GitHub Desktop.
Adds now playing indicator from spotify to i3status. Better to use playerctl and i3blocks, but it works
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 | sed -e 's/[\/&]/\\&/g') | |
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 | sed -e 's/[\/&]/\\&/g') | |
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 | sed -e 's/[\/&]/\\&/g') | |
if [ "$spotify_status" = "Playing" ] ; then | |
echo $(echo "$line" | sed 's/{\"name/{\"name\":\"music\",\"full_text\":\" : '"$spotify_artist"' - '"$spotify_song"'\"},{\"name/') || 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