aboutsummaryrefslogtreecommitdiff
path: root/scripts/media_is_spotify_playing.sh
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2016-01-11 20:54:46 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2016-01-11 20:54:46 +0100
commit90044a0452c64d599f97a4881678a421f3dd357d (patch)
treeb4d9137e8ea3dbcfc1b975f3257029cde7fb45cb /scripts/media_is_spotify_playing.sh
parent6d2a88231a0257e8f21b29022f0b69c8a8f2231b (diff)
downloaddotfiles-90044a0452c64d599f97a4881678a421f3dd357d.tar.gz
dotfiles-90044a0452c64d599f97a4881678a421f3dd357d.zip
rework media_control to work with pulseaudio
1) outsource check if spotify is playing in media_is_spotify_playing.sh 2) use media_is_spotify_playing in media_status.sh 3) rework media_control using media_is_spotify_playing.sh
Diffstat (limited to 'scripts/media_is_spotify_playing.sh')
-rwxr-xr-xscripts/media_is_spotify_playing.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/media_is_spotify_playing.sh b/scripts/media_is_spotify_playing.sh
new file mode 100755
index 0000000..8c10aad
--- /dev/null
+++ b/scripts/media_is_spotify_playing.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+spotify_running=false
+
+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
+fi
+
+echo $spotify_running
+if [[ $spotify_running == "true" ]]
+then
+ exit 0
+else
+ exit 1
+fi