Created
October 5, 2020 04:45
-
-
Save ayosec/bf6f608c3c4871325293d1ea43e8452e to your computer and use it in GitHub Desktop.
playerctl: skip metada to control music
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
case "${1:-}" in | |
next) | |
MEMBER=Next | |
;; | |
previous) | |
MEMBER=Previous | |
;; | |
play) | |
MEMBER=Play | |
;; | |
pause) | |
MEMBER=Pause | |
;; | |
play-pause) | |
MEMBER=PlayPause | |
;; | |
*) | |
echo "Usage: $0 next|previous|play|pause|play-pause" | |
exit 1 | |
;; | |
esac | |
exec dbus-send \ | |
--print-reply \ | |
--dest="org.mpris.MediaPlayer2.$(playerctl -l | head -n 1)" \ | |
/org/mpris/MediaPlayer2 \ | |
"org.mpris.MediaPlayer2.Player.$MEMBER" |
Why is line 34 required? The command seems to not work without it.
I guess that it depends on the player. I'm using this script with an old version of spotifyd. If I remove the --print-reply
option, the action is not executed.
Why is line 34 required? The command seems to not work without it.
I guess that it depends on the player. I'm using this script with an old version of spotifyd. If I remove the
--print-reply
option, the action is not executed.
Yes, even for me (latest version of spotifyd) it does not work, but I was unable to understand why not printing the reply makes it not work, maybe something to do with dbus or spotifyd.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why is line 34 required? The command seems to not work without it.