aboutsummaryrefslogtreecommitdiff
path: root/scripts/media_control.sh
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2015-11-25 20:17:15 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2015-11-27 02:44:53 +0100
commite02542fca8dfe25bc22346b55b35d2a6cbc0c35c (patch)
tree82b66ccf80fa72371df9fc36ed4fa94bb2fddf63 /scripts/media_control.sh
parent2a9bfb8a3c90031cea661b1de69caca885b21530 (diff)
downloaddotfiles-e02542fca8dfe25bc22346b55b35d2a6cbc0c35c.tar.gz
dotfiles-e02542fca8dfe25bc22346b55b35d2a6cbc0c35c.zip
rework media buttons control to function with spotify
also remove bash wrapper for fish scripts and just use bash scripts
Diffstat (limited to 'scripts/media_control.sh')
-rw-r--r--scripts/media_control.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/media_control.sh b/scripts/media_control.sh
new file mode 100644
index 0000000..c0ce02a
--- /dev/null
+++ b/scripts/media_control.sh
@@ -0,0 +1,36 @@
+# NOTE:
+# if spotify is running toggle is consumed by spotify.
+
+#!/bin/bash
+
+# arg parsing
+if [ "$1" = "toggle" ]
+then
+ spotify_cmd="PlayPause"
+elif [ "$1" = "next" ]
+then
+ spotify_cmd="Next"
+elif [ "$1" = "prev" ]
+then
+ spotify_cmd="Previous"
+fi
+
+if [ "$spotify_cmd" != "" ]
+then
+ # can't be sure if spotify was running and should play again
+ if [ "$spotify_cmd" = "PlayPause" ]
+ then
+ if [ "$(ps -A | grep spotify)" != "" ]
+ then
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.$spotify_cmd
+ else
+ mpc $1
+ fi
+ elif [ "$(lsof | grep /dev/snd | grep spotify)" != "" ]
+ then
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.$spotify_cmd
+ elif [ "$(mpc | grep '\[' | cut -f1 -d' ')" != "" ]
+ then
+ mpc $1 &>/dev/null
+ fi
+fi