{"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

Controlling Spotify<\/h2>\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: sudo apt-get install qdbus-qt5<\/code><\/p>\n\n\n\n

Pausing Spotify<\/h4>\n\n\n\n

This neat little command does everything you wish for:<\/p>\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

We got you with this one!<\/p>\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

First off, I’ve put these commands in bash files, like below:<\/p>\n\n\n\n

\"\"<\/a><\/figure>\n\n\n\n

Make sure these files are executable (chmod +x stop-spotify.sh<\/code>)<\/p>\n\n\n\n

Then, for the cronjob part, we have the following setup (start at 8am, stop at 6pm):<\/p>\n\n\n\n

0 8 * * * \/home\/screen\/start-jazz.sh\n0 18 * * * \/home\/screen\/stop-spotify.sh<\/code><\/pre>\n\n\n\n

That’s it!<\/strong> Happy automating!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"

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. I would love it if the lights and […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\nControl Spotify from the command line in Ubuntu - Marinus Klasen<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Control Spotify from the command line in Ubuntu - Marinus Klasen\" \/>\n<meta property=\"og:description\" content=\"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. I would love it if the lights and […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/\" \/>\n<meta property=\"og:site_name\" content=\"Marinus Klasen\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:author\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-21T09:05:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-10-21T09:07:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433-1024x167.png\" \/>\n<meta name=\"author\" content=\"Marinus Klasen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/marinusklasen\" \/>\n<meta name=\"twitter:site\" content=\"@marinusklasen\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marinus Klasen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/\"},\"author\":{\"name\":\"Marinus Klasen\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"headline\":\"Control Spotify from the command line in Ubuntu\",\"datePublished\":\"2021-10-21T09:05:57+00:00\",\"dateModified\":\"2021-10-21T09:07:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/\"},\"wordCount\":194,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"image\":{\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433-1024x167.png\",\"articleSection\":[\"General\"],\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/\",\"url\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/\",\"name\":\"Control Spotify from the command line in Ubuntu - Marinus Klasen\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433-1024x167.png\",\"datePublished\":\"2021-10-21T09:05:57+00:00\",\"dateModified\":\"2021-10-21T09:07:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#primaryimage\",\"url\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433.png\",\"contentUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433.png\",\"width\":1992,\"height\":324},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mklasen.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"General\",\"item\":\"https:\/\/mklasen.com\/general\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Control Spotify from the command line in Ubuntu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mklasen.com\/#website\",\"url\":\"https:\/\/mklasen.com\/\",\"name\":\"Marinus Klasen\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mklasen.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"nl-NL\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\",\"name\":\"Marinus Klasen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"contentUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"width\":1500,\"height\":1000,\"caption\":\"Marinus Klasen\"},\"logo\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\"},\"description\":\"Marinus has been working in software\/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge. Marinus Klasen on Twitter\",\"sameAs\":[\"http:\/\/facebook.com\/marinus.klasen\",\"https:\/\/nl.linkedin.com\/in\/marinusklasen\",\"https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Control Spotify from the command line in Ubuntu - Marinus Klasen","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/","og_locale":"nl_NL","og_type":"article","og_title":"Control Spotify from the command line in Ubuntu - Marinus Klasen","og_description":"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. I would love it if the lights and […]","og_url":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/","og_site_name":"Marinus Klasen","article_publisher":"http:\/\/facebook.com\/marinus.klasen","article_author":"http:\/\/facebook.com\/marinus.klasen","article_published_time":"2021-10-21T09:05:57+00:00","article_modified_time":"2021-10-21T09:07:09+00:00","og_image":[{"url":"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433-1024x167.png"}],"author":"Marinus Klasen","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/marinusklasen","twitter_site":"@marinusklasen","twitter_misc":{"Written by":"Marinus Klasen","Est. reading time":"2 minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#article","isPartOf":{"@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/"},"author":{"name":"Marinus Klasen","@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"headline":"Control Spotify from the command line in Ubuntu","datePublished":"2021-10-21T09:05:57+00:00","dateModified":"2021-10-21T09:07:09+00:00","mainEntityOfPage":{"@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/"},"wordCount":194,"commentCount":0,"publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"image":{"@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433-1024x167.png","articleSection":["General"],"inLanguage":"nl-NL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/","url":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/","name":"Control Spotify from the command line in Ubuntu - Marinus Klasen","isPartOf":{"@id":"https:\/\/mklasen.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#primaryimage"},"image":{"@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433-1024x167.png","datePublished":"2021-10-21T09:05:57+00:00","dateModified":"2021-10-21T09:07:09+00:00","breadcrumb":{"@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/"]}]},{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#primaryimage","url":"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433.png","contentUrl":"https:\/\/mklasen.com\/content\/uploads\/2021\/10\/Markup-on-2021-10-21-at-110433.png","width":1992,"height":324},{"@type":"BreadcrumbList","@id":"https:\/\/mklasen.com\/control-spotify-from-the-command-line-in-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mklasen.com\/"},{"@type":"ListItem","position":2,"name":"General","item":"https:\/\/mklasen.com\/general\/"},{"@type":"ListItem","position":3,"name":"Control Spotify from the command line in Ubuntu"}]},{"@type":"WebSite","@id":"https:\/\/mklasen.com\/#website","url":"https:\/\/mklasen.com\/","name":"Marinus Klasen","description":"","publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mklasen.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"nl-NL"},{"@type":["Person","Organization"],"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29","name":"Marinus Klasen","image":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/","url":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","contentUrl":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","width":1500,"height":1000,"caption":"Marinus Klasen"},"logo":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/"},"description":"Marinus has been working in software\/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge. Marinus Klasen on Twitter","sameAs":["http:\/\/facebook.com\/marinus.klasen","https:\/\/nl.linkedin.com\/in\/marinusklasen","https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen"]}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Marinus Klasen","author_link":"https:\/\/mklasen.com\/author\/mklasen\/"},"_links":{"self":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/780"}],"collection":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/comments?post=780"}],"version-history":[{"count":2,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/780\/revisions"}],"predecessor-version":[{"id":783,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/780\/revisions\/783"}],"wp:attachment":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/media?parent=780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/categories?post=780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/tags?post=780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}