Skip to content

Instantly share code, notes, and snippets.

@htr
Last active February 22, 2021 18:23
Show Gist options
  • Save htr/6267335 to your computer and use it in GitHub Desktop.
Save htr/6267335 to your computer and use it in GitHub Desktop.
spotify from xmonad
{-# LANGUAGE OverloadedStrings #-}
import DBus
import DBus.Client
spotifyCtrl :: Client -> MemberName -> X ()
spotifyCtrl client command = liftIO $ do
call_ client
(methodCall "/org/mpris/MediaPlayer2" "org.mpris.MediaPlayer2.Player" command) {
methodCallDestination = Just "org.mpris.MediaPlayer2.spotify" }
return ( )
main = do
client <- connectSession
xmonad $ ... Config { } `additionalKeysP` (myKeys client)
myKeys dbusClient = [ ("<XF86Launch1>", spotifyCtrl dbusClient "PlayPause")
, ("<XF86AudioPlay>", spotifyCtrl dbusClient "PlayPause")
, ("<XF86AudioNext>", spotifyCtrl dbusClient "Next")
, ("<XF86AudioPrev>", spotifyCtrl dbusClient "Previous")
, ("<XF86AudioStop>", spotifyCtrl dbusClient "Stop")
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment