Skip to content

Instantly share code, notes, and snippets.

@mikaelz
Created May 11, 2015 16:07
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelz/b85c8d97fcee55c33b88 to your computer and use it in GitHub Desktop.
Save mikaelz/b85c8d97fcee55c33b88 to your computer and use it in GitHub Desktop.
Awesome WM config for multimedia keys to control Spotify
awful.key({ }, "XF86AudioPlay", function () awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause") end),
awful.key({ }, "XF86AudioNext", function () awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next") end),
awful.key({ }, "XF86AudioPrev", function () awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous") end)
@gunar
Copy link

gunar commented Mar 1, 2017

WOOO

@gunar
Copy link

gunar commented Mar 1, 2017

I've wrote a helper function:

-- {{{ Spotify
function sendToSpotify(command)
  return function ()
    awful.util.spawn_with_shell("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player." .. command)
  end
end
-- }}}

-- {{{ Key bindings
globalkeys = awful.util.table.join(globalkeys,
    -- {{{ Spotify 
    awful.key({ modkey }, "s", sendToSpotify("PlayPause")), --  XF86AudioPlay
    awful.key({ modkey }, "d", sendToSpotify("Next")), -- XF86AudioNext
    awful.key({ modkey }, "a", sendToSpotify("Previous")), -- XF86AudioPrev
    -- }}}

https://github.com/gunar/dotfiles/commit/e2eb4af9c1376a3dde0c3d6613a9aaba064dfd50

@squiter
Copy link

squiter commented May 20, 2017

There is some way to make these keys work for Spotify and Rhythmbox?

@gunar
Copy link

gunar commented Jun 10, 2017

Is this broken in the latest release of Spotify?

@mikaelz
Copy link
Author

mikaelz commented Jun 13, 2017

Works for me with

awesome v4.1 (Technologic)
 • Compiled against Lua 5.3.4 (running with Lua 5.3)
 • D-Bus support: ✔
 • execinfo support: ✔
 • xcb-randr version: 1.5
 • LGI version: 0.9.1

Check your Dbus support
Try executing only the dbus command dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

@daraul
Copy link

daraul commented Jun 26, 2018

I just set this up on my machine: https://github.com/acrisci/playerctl

Had it working fine on i3wm, working on adding it to awesome right now.

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