Sanchayan Maity
772b878e0b
Scope of the project - Scrobble the tracks to last.fm viz. a last.fm scrobbler - Build a terminal UI for interacting with media player daemon For the UI, we will the brick library and for the scrobbler we will use mpris and liblastfm.
34 lines
812 B
Haskell
34 lines
812 B
Haskell
module Main where
|
|
|
|
import Control.Concurrent ( threadDelay )
|
|
import Control.Monad ( forever )
|
|
import Control.Monad.IO.Class ( MonadIO(liftIO) )
|
|
import DBus.Mpris
|
|
( current,
|
|
PlaybackStatus,
|
|
Config(playbackStatusHook),
|
|
liftMpris,
|
|
mpris,
|
|
def,
|
|
Callback,
|
|
getPlayer,
|
|
Player(Player) )
|
|
|
|
mpdPlaybackStatusHook :: Callback PlaybackStatus
|
|
mpdPlaybackStatusHook = do
|
|
player <- liftMpris current
|
|
case player of
|
|
Nothing -> liftIO . print $ "Failed to retrieve DBus"
|
|
(Just busName) -> do
|
|
(Player _ _ _ _ m) <- liftMpris $ getPlayer busName
|
|
liftIO . putStrLn $ "Status changed " ++ show m
|
|
|
|
config :: Config
|
|
config =
|
|
def
|
|
{ playbackStatusHook = mpdPlaybackStatusHook
|
|
}
|
|
|
|
main :: IO ()
|
|
main = mpris config (liftIO $ forever $ threadDelay 800000)
|