Skip to content

Instantly share code, notes, and snippets.

Created January 22, 2013 14:34
What would you like to do?
configure spotify for linux shortcut keys
#@see for details
sudo apt-get install xbindkeys
####now put the following in ~/.xbindkeysrc:
"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.Prev"
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next"
##### Now run xbindkeys and put '/usr/bin/xbindkeys' in 'startup applications' for your user account
Copy link

azxcqer commented Apr 25, 2018


If anyone wanders around here from some search engine I this still works. I'd just add that you may need to restart Spotify for it to work.

Copy link

CAJan93 commented Oct 27, 2018

Thank you very much, works like a charm.

Also, if you do not like to put the commands on the Audio-keys, you can use any other key for it. For example I am using the F8 to stop/start and F9 to play the next song

Copy link

This worked great on Ubuntu 19.04 (with the slight change below), great to bind play/pause to scroll lock and volume to pause/break on a keyboard without media keys.

Previous song did need a change though, "Prev" at the end of the line needed to be "Previous", otherwise nothing happens:

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

Copy link

cossio commented May 21, 2020


Copy link

avlm commented Jul 9, 2020

This is great! Thanks! Chrome will not steal my media keys anymore hahaha 😄

On Ubuntu budgie it needed a full restart, not just spotify.

Copy link

tmuryn commented Jan 6, 2022

does anyone have commands for volume up/down?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment