diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/media_print_spotify_info.sh | 9 | ||||
| -rwxr-xr-x | scripts/media_status.sh | 44 |
2 files changed, 28 insertions, 25 deletions
diff --git a/scripts/media_print_spotify_info.sh b/scripts/media_print_spotify_info.sh new file mode 100755 index 0000000..3171023 --- /dev/null +++ b/scripts/media_print_spotify_info.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +metadata=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata') + +artist=$(echo "$metadata" | egrep -A 2 "artist" | egrep -v "artist" | egrep -v "array" | cut -b 27- | cut -d '"' -f 1 | egrep -v ^$) + +title=$(echo "$metadata" | egrep -A 1 "title" | egrep -v "title" | cut -b 44- | cut -d '"' -f 1| egrep -v ^$) + +echo $artist - $title diff --git a/scripts/media_status.sh b/scripts/media_status.sh index 22116e0..a7218ee 100755 --- a/scripts/media_status.sh +++ b/scripts/media_status.sh @@ -1,44 +1,38 @@ #!/bin/bash -mpd_running=$(mpc 2>/dev/null | grep "\[playing\]") -spotify_running=$(./media_is_spotify_playing.sh) +mpd_playing=$(mpc 2>/dev/null | grep "\[playing\]") +spotify_playing=$($HOME/.dotfiles/scripts/media_is_spotify_playing.sh) -if pgrep spotify &>/dev/null +if [[ $spotify_playing == "true" ]] then - if $spotify_running && [[ $mpd_running != "" ]] + if [[ $mpd_playing != "" ]] then - echo spotify and mpd running + echo spotify and mpd playing else - metadata=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata') + pb_status="" if [[ $metadata == *"spotify:ad"* ]] then echo "Spotify: ad :/" else - artist=$(echo "$metadata" | egrep -A 2 "artist" | egrep -v "artist" | egrep -v "array" | cut -b 27- | cut -d '"' -f 1 | egrep -v ^$) - - title=$(echo "$metadata" | egrep -A 1 "title" | egrep -v "title" | cut -b 44- | cut -d '"' -f 1| egrep -v ^$) - - if $spotify_running - then - pb_status="▶" - else - pb_status="▐▐" - fi - - echo Spotify: $pb_status $artist - $title + echo Spotify: "▶" $($HOME/.dotfiles/scripts/media_print_spotify_info.sh) fi fi +elif [[ $mpd_playing != "" ]] +then + if type mpc &>/dev/null + then + echo MPD: "▶" $(mpc current) + else + echo "for mpd status mpc is needed" + fi +elif pgrep spotify &>/dev/null +then + echo Spotify: "▐▐" $($HOME/.dotfiles/scripts/media_print_spotify_info.sh) elif pgrep mpd &>/dev/null then if type mpc &>/dev/null then - if [[ $mpd_running != "" ]] - then - pb_status="▶" - else - pb_status="▐▐" - fi - echo MPD: $pb_status $(mpc current) + echo MPD: "▐▐" $(mpc current) else echo "for mpd status mpc is needed" fi |
