aboutsummaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
Diffstat (limited to 'extras')
-rwxr-xr-xextras/HOME/.local/bin/spotify-control26
1 files changed, 23 insertions, 3 deletions
diff --git a/extras/HOME/.local/bin/spotify-control b/extras/HOME/.local/bin/spotify-control
index 1bd7bcc..34a2633 100755
--- a/extras/HOME/.local/bin/spotify-control
+++ b/extras/HOME/.local/bin/spotify-control
@@ -6,16 +6,36 @@ then
exit
fi
+target_hint="spotify"
+while [[ "$1" == --* ]] ; do
+ arg="$1"
+ case "$arg" in
+ --target-hint=*)
+ target_hint="${arg/--target-hint=/}"
+ ;;
+ *)
+ echo "Bad Argument $1"
+ exit 1
+ ;;
+ esac
+ shift
+done
+
# Some targets (spotifyd) don't have a stable dbus path.
-target="$( \
+targets="$( \
dbus-send \
--print-reply \
--dest=org.freedesktop.DBus \
/org/freedesktop/DBus org.freedesktop.DBus.ListNames \
| sed 's#.*string \"\(.*\)"#\1#' \
- | grep MediaPlayer2 \
- | head -n1)"
+ | grep MediaPlayer2)"
+# Prefer the target hint.
+target="$(echo "$targets" | grep -i "$target_hint" | head -n1)"
+if [ -z "$target" ] ; then
+ # If no spotify, pick an arbitrary one
+ target="$(echo "$targets" | head -n1)"
+fi
function mpris2_dbus_player_do {
dbus-send \