Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE OverloadedStrings #-}
- import Data.Maybe
- import DBus
- import DBus.Client
- import DBus.Socket
- main = do
- sessionBus <- connectSession
- socketPath <- getPulseAddress sessionBus
- case socketPath of
- Nothing -> putStrLn "FAIL can't find pulseaudio socket."
- Just s -> do
- putStr $ "... connecting to pulseaudio at: " ++ s
- pulseBus <- pulseConnect socketPath
- putStrLn $ "\rOK "
- getPulseAddress :: Client -> IO (Maybe String)
- getPulseAddress client = do
- reply <- call_ client (methodCall "/org/pulseaudio/server_lookup1"
- "org.freedesktop.DBus.Properties"
- "Get")
- { methodCallDestination = Just "org.PulseAudio1"
- , methodCallBody = [toVariant ("org.PulseAudio.ServerLookup1" :: String),
- toVariant ("Address" :: String)]}
- return $ (fromVariant =<< fromVariant ((methodReturnBody reply) !! 0))
- pulseConnect :: Maybe String -> Maybe (IO Socket)
- pulseConnect Nothing = Nothing
- pulseConnect (Just s) = maybe Nothing (Just . open) $ parseAddress s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement