From 667eb047290f24ddd3f90a3034fba917f40c5f12 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 11 Jan 2016 19:16:24 +0100 Subject: make i3bar music info work with alsa and pa 1) change conkyrc file to execute new media_status script 2) add media_status script which displayes information for the following programs: + spotify + mpd If none of the programms is running "no music" will be printed. 3) delete unnecessary script --- scripts/media_status.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 scripts/media_status.sh (limited to 'scripts/media_status.sh') diff --git a/scripts/media_status.sh b/scripts/media_status.sh new file mode 100755 index 0000000..850a0c5 --- /dev/null +++ b/scripts/media_status.sh @@ -0,0 +1,77 @@ +#!/bin/bash +mpd_running=$(mpc | grep "\[playing\]") + +if pgrep spotify &>/dev/null +then + if type pacmd &>/dev/null + then + output=$(pacmd list-sink-inputs) + state="" + spotify_running=false + + while read -r line; do + if [[ $line == *state* ]] + then + if [[ $line == *RUNNING* ]] + then + state="RUNNING" + else + state="" + fi + fi + + if [[ $line == *application.name* ]] + then + if [[ $state == "RUNNING" ]] && [[ $line == *Spotify* ]] + then + spotify_running=true + break + fi + fi + done <<< "$output" + elif lsof | grep /dev/snd | grep spotify &>/dev/null + then + spotify_running=true + fi + + if $spotify_running && [[ $mpd_running != "" ]] + then + echo spotify and mpd running + 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') + + 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 + fi + fi +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) + else + echo "for mpd status mpc is needed" + fi +else + echo no music +fi -- cgit v1.2.3