Basic controls via command line

Solved!
Reply

Basic controls via command line

doudoujack
Casual Listener

Hello everyone,

 

I would like to be able to control some basic functions via command line like play/pause, could someone help?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Solution!

Re: Basic controls via command line

JasonLG1979
Music Fan

Or you could just use dbus-send directly:

Play:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play

Pause:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause

Play/Pause toggle:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

Previous:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

Next:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

Volume and seeking doesn't work via MPRIS because their MPRIS implementation is broken.

5 Replies

Re: Basic controls via command line

edaubert
Regular

Hi

 

https://gist.github.com/wandernauta/6800547

 

This has made a good work for me.

 

Hope it will help.

Highlighted
Solution!

Re: Basic controls via command line

JasonLG1979
Music Fan

Or you could just use dbus-send directly:

Play:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play

Pause:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause

Play/Pause toggle:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

Previous:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

Next:

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

Volume and seeking doesn't work via MPRIS because their MPRIS implementation is broken.

Re: Basic controls via command line

Valeyard1
Casual Listener

It doesn't work for me, when i type these commands, dbus sends this error:

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.mpris.MediaPlayer2.spotify was not provided by any .service files

Do you know how can i fix it?

Re: Basic controls via command line

JasonLG1979
Music Fan

On a standard install it should work, I have not tested them with the snap or flatpak. I know that the flatpak versions has issues. For example you can't raise it via dbus or MPRIS last time I checked. Spotify has to be running of course for any of the commands to work also.

I really wish they would open up their API. I don't see the logic of keeping the API closed and then releasing a garbage desktop app? Don't get me wrong, I love the spotify service (So much I actaully pay for it,lol!!!) But let's face it the desktop app is **bleep**... If they opened up the API it would take about a week and you'd have at least a couple awesome native Linux Spotify apps that they would not have to worry about.

Re: Basic controls via command line

doudoujack
Casual Listener

Thanks this would be I guess a good complete solution! I was searching for a really basic and simple solution so I marked the dbus reply as solution but thanks for this hint as well!

Best

Eds

SUGGESTED POSTS