aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i3/conkyrc.json15
-rwxr-xr-xscripts/media_status.sh77
-rw-r--r--scripts/spotify-artist-title.sh14
3 files changed, 78 insertions, 28 deletions
diff --git a/i3/conkyrc.json b/i3/conkyrc.json
index ff2c6e2..7b6a942 100644
--- a/i3/conkyrc.json
+++ b/i3/conkyrc.json
@@ -44,20 +44,7 @@ TEXT
############### music/ spotify/ mpd ###################
${if_match "${nodename_short}"!="fishbowl"}
- ${if_match "${exec lsof | grep /dev/snd | grep spotify}"!=""} # spotify using sound devices -> is playing
- {"name": "indicator", "separator": false ,"color": "\#ffffff", "full_text": "Spotify:"},
- {"name": "artist_title", "color": "\#ffffff", "full_text": "${exec bash ~/.dotfiles/scripts/spotify-artist-title.sh}"},
-
- ${else} ${if_mpd_playing}
- {"name": "indicator", "separator": false, "color": "\#ffffff", "full_text": "MPD:"},
- {"name": "statusSymbol", "color": "\#ffffff", "separator": false,
- "full_text": ${if_match "${mpd_status}"=="Playing"}"▶"${else}"▐▐"${endif}},
-
- {"name": "music", "color": "\#ffffff", "full_text":"${mpd_title} ${mpd_bar}"},
- ${else}
- {"name": "nomusic", "color": "\#ffffff", "full_text": "no music"},
- ${endif}
- ${endif}
+ {"name":"music", "color": "\#ffffff", "full_text": "${exec ~/.dotfiles/scripts/media_status.sh}"},
${endif}
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
diff --git a/scripts/spotify-artist-title.sh b/scripts/spotify-artist-title.sh
deleted file mode 100644
index 62494b8..0000000
--- a/scripts/spotify-artist-title.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/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')
-
-if [[ $metadata == *"spotify:ad"* ]]
-then
- echo "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 ^$)
-
- echo $artist - $title
-fi