Skip to content

Instantly share code, notes, and snippets.

@mikaelz
Created May 11, 2015 16:07
Show Gist options
  • Select an option

  • Save mikaelz/b85c8d97fcee55c33b88 to your computer and use it in GitHub Desktop.

Select an option

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

gunar commented Mar 1, 2017

Copy link
Copy Markdown

WOOO

@gunar

gunar commented Mar 1, 2017

Copy link
Copy Markdown

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

squiter commented May 20, 2017

Copy link
Copy Markdown

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

@gunar

gunar commented Jun 10, 2017

Copy link
Copy Markdown

Is this broken in the latest release of Spotify?

@mikaelz

mikaelz commented Jun 13, 2017

Copy link
Copy Markdown
Author

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

daraul commented Jun 26, 2018

Copy link
Copy Markdown

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