{"id":780,"date":"2021-10-21T09:05:57","date_gmt":"2021-10-21T09:05:57","guid":{"rendered":"https:\/\/mklasen.com\/?p=780"},"modified":"2021-10-21T09:07:09","modified_gmt":"2021-10-21T09:07:09","slug":"control-spotify-from-the-command-line-in-ubuntu","status":"publish","type":"post","link":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/","title":{"rendered":"Control Spotify from the command line in Ubuntu"},"content":{"rendered":"\n
I like automation, I really do. Especially when it comes down to the atmosphere. I moved to an office recently and when I walk in I want things to be in motion; In this specific case I want music to be playing already when I come in. <\/p>\n\n\n\n
I would love it if the lights and climate control would automatically turn on, but well – I don’t really have control over that. I do have control over my office server and the connected soundbar!<\/p>\n\n\n\n
I had no clue that this was possible at all, but apparently it’s quite easy. When you have Spotify running on Ubuntu, the only other thing you need is qbus. Install it with: This neat little command does everything you wish for:<\/p>\n\n\n\n We got you with this one!<\/p>\n\n\n\n First off, I’ve put these commands in bash files, like below:<\/p>\n\n\n\nsudo apt-get install qdbus-qt5<\/code><\/p>\n\n\n\n
Pausing Spotify<\/h4>\n\n\n\n
qdbus org.mpris.MediaPlayer2.spotify \/org\/mpris\/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause<\/code><\/p>\n\n\n\n
Playing a specific album\/playlist<\/h4>\n\n\n\n
qdbus org.mpris.MediaPlayer2.spotify \/org\/mpris\/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri spotify:playlist:69vYU5GaL6K157BAlMvSCf<\/code><\/p>\n\n\n\n
So, how about these cronjobs?<\/h4>\n\n\n\n