File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -284,14 +284,19 @@ __np_playerctl() {
284284
285285__np_spotify () {
286286 if shell_is_linux; then
287- 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)
288- if [ " $? " -eq 0 ] && [ -n " $metadata " ]; then
289- # 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.
290- state=$( qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus)
291- if [[ $state == " Playing" ]]; then
292- artist=$( echo " $metadata " | grep -PA2 " string\s\" xesam:artist\" " | tail -1 | grep -Po " (?<=\" ).*(?=\" )" )
293- track=$( echo " $metadata " | grep -PA1 " string\s\" xesam:title\" " | tail -1 | grep -Po " (?<=\" ).*(?=\" )" )
294- np=$( echo " ${artist} - ${track} " )
287+ if type tasklist.exe > /dev/null 2>&1 ; then # WSL
288+ np=$( tasklist.exe /APPS /fo list /v /fi " IMAGENAME eq Spotify.exe" | grep " - " | cut -d" " -f3-)
289+ np=" ${np// [$'\t\r\n']} "
290+ else
291+ 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)
292+ if [ " $? " -eq 0 ] && [ -n " $metadata " ]; then
293+ # 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.
294+ state=$( qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus)
295+ if [[ $state == " Playing" ]]; then
296+ artist=$( echo " $metadata " | grep -PA2 " string\s\" xesam:artist\" " | tail -1 | grep -Po " (?<=\" ).*(?=\" )" )
297+ track=$( echo " $metadata " | grep -PA1 " string\s\" xesam:title\" " | tail -1 | grep -Po " (?<=\" ).*(?=\" )" )
298+ np=$( echo " ${artist} - ${track} " )
299+ fi
295300 fi
296301 fi
297302 elif shell_is_osx; then
You can’t perform that action at this time.
0 commit comments