-
-
Save jbonney/5743509 to your computer and use it in GitHub Desktop.
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay | |
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop | |
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext | |
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious |
Thank you very much!
Awesome, thanks!
great job
@liquid2026 worked like a charm, thx!
Thanks guys! :D
Working in Xubuntu 16.04.3
thanks!
Perfect, thanks!
Thanks!
Thanks @sjug !
Still works, thanks!!
Thank you very much! :)
Bindsym version for the i3wm people using media keys (.i3/config)
# Bind media keys to spotify play, stop, next, previous
bindsym XF86AudioPlay exec dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
bindsym XF86AudioStop exec dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop
bindsym XF86AudioNext exec dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
bindsym XF86AudioPrev exec dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
Those work absolutely fine for me on Ubuntu 17.10 when defined as "Custom Shortcuts" via Gnome Settings.
To improve upon @barnaba's example for I3 users, and for those preferring direct media keys on hardware without fiddling with the Gnome controls UI:
# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5% #increase sound volume
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5% #decrease sound volume
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle # mute sound
# Media keys
## Using [playerctl](https://github.com/acrisci/playerctl)
bindsym XF86AudioPrev exec --no-startup-id playerctl previous
bindsym XF86AudioNext exec --no-startup-id playerctl next
bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause
bindsym XF86AudioPause exec --no-startup-id playerctl pause
bindsym XF86AudioStop exec --no-startup-id playerctl stop
## Non-playerctl option for Ubuntu
# bindsym XF86AudioPrev exec --no-startup-id "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous"
# bindsym XF86AudioNext exec --no-startup-id "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"
# bindsym XF86AudioPlay exec --no-startup-id "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
# bindsym XF86AudioPause exec --no-startup-id "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause"
# bindsym XF86AudioStop exec --no-startup-id "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop"
Thanks! Worked very well on a DELL 5777 laptop with a vanilla Xubuntu 16.04!
T.K.S!!!
Worked very well on a Lenovo IdeaPad 320 laptop with a Xubuntu 17.10 artful!
To date https://gist.github.com/jbonney/5743509#gistcomment-1422561 is still working perfectly on xfce/ubuntu studio 👏
For anyone curious which other commands the spotify client supports try:
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Introspectable.Introspect
This lists another method "Seek". Unfortunately it doesn't seem to do anything though, because no matter what value I try for Offset, it doesn't have any effect:
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:10
Still wanted to leave it here in case anyone else wants to figure this out. Seemed useful.
Is there a command for the "15 seconds" key in Spotify?
It's work on Debian 10
Debian 10 - Buster.
Works just fine.
For anyone else with this issue: In Ubuntu 18.04 using the snap version of Spotify the media keys work out of the box, except that Chrome is a little greedy and captures these keys (presumably to control YouTube content and the like). The good news is that this can be disabled here:
chrome://flags/#hardware-media-key-handling. After doing so the media key events will pass-through to Spotify again.
Working great xubuntu 18.04
Thanks a lot!
@chfritz 10x so much that helped a lot
And for anyone interested in querying the currently running song, this can be gotten from:
dbus-send --dest=org.mpris.MediaPlayer2.spotify --print-reply /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Metadata
Sample output:
method return time=1579663676.086557 sender=:1.134 -> destination=:1.420 serial=406 reply_serial=2
variant array [
dict entry(
string "mpris:trackid"
variant string "spotify:track:3d8Awbi4CFYp4Wp231MqdS"
)
dict entry(
string "mpris:length"
variant uint64 433000000
)
dict entry(
string "mpris:artUrl"
variant string "https://open.spotify.com/image/ab67616d00001e02bd3afe3a0169e70901d2933e"
)
dict entry(
string "xesam:album"
variant string "Total 7"
)
dict entry(
string "xesam:albumArtist"
variant array [
string "Various Artists"
]
)
dict entry(
string "xesam:artist"
variant array [
string "Oxia"
]
)
dict entry(
string "xesam:autoRating"
variant double 0.01
)
dict entry(
string "xesam:discNumber"
variant int32 2
)
dict entry(
string "xesam:title"
variant string "Domino"
)
dict entry(
string "xesam:trackNumber"
variant int32 11
)
dict entry(
string "xesam:url"
variant string "https://open.spotify.com/track/3d8Awbi4CFYp4Wp231MqdS"
)
]
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:10
Find out that seek value is specified in microseconds. So you have specify int64:1000000
for 1 sec. It works for me.
This works with Spotify, but then YouTube stops working (running from Brave browser). Is there a way to keep both Spotify and YouTube?
Bless every little part of you, have been searching for this solution in forever! Can't thank you enough! <3