Last active
February 22, 2021 18:23
-
-
Save htr/6267335 to your computer and use it in GitHub Desktop.
spotify from xmonad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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