aboutsummaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2023-02-03 11:02:06 -0700
committerJosh Rahm <rahm@google.com>2023-02-03 11:02:06 -0700
commit1a102c45a442490c1f1efdcf769b2ead579cfff6 (patch)
treed45c07bc7d3ee8683eabb10e7caf2ab2479db7a7 /extras
parente027c8463b9d46562c5c848bdc36f52e92d98a7b (diff)
downloadrde-1a102c45a442490c1f1efdcf769b2ead579cfff6.tar.gz
rde-1a102c45a442490c1f1efdcf769b2ead579cfff6.tar.bz2
rde-1a102c45a442490c1f1efdcf769b2ead579cfff6.zip
Make spotify-control more flexible
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 \