citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

commit 9309afd07738ef338db435c2cdbff484a1bcf73d
parent e0bda8c55cd56d9626aee626cfa651a1a7ffb68f
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 15 Dec 2021 17:02:33 -0800

playpause: multiple targets

Diffstat:
Mbin/spotify-playpause | 19+++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/bin/spotify-playpause b/bin/spotify-playpause @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -eou pipefail + bus=$(dbus-send \ --print-reply=literal \ --dest=org.freedesktop.DBus \ @@ -8,7 +10,20 @@ bus=$(dbus-send \ org.freedesktop.DBus.ListNames | tr ' ' '\n' | grep 'org.mpris.MediaPlayer2' | - head -n 1 + grep -v qutebrowser ) -dbus-send --print-reply --dest="$bus" /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause +count=$(wc -l <<<"$bus") + +playpause() { + dbus-send --print-reply --dest="$1" /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause +} + +if [ $count -eq 1 ]; then + playpause "$bus" + exit 0 +fi + +bus=$(<<<"$bus" sed 's,^org.mpris.MediaPlayer2.,,g' | dmenu -i -p "playpause" -l 7) + +playpause "org.mpris.MediaPlayer2.$bus"