diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2015-04-04 22:00:51 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2015-04-04 22:00:51 +0900 |
commit | 209816bcb2d2e84dd29cf5baf08f4ba708d483aa (patch) | |
tree | 010a809aa61b73ac78259c3f008c06e248c9f64a | |
parent | 7545fa7b81876fdbb174d529690eec59349f072c (diff) | |
download | srem-209816bcb2d2e84dd29cf5baf08f4ba708d483aa.tar.gz |
posix notifications library complete
-rw-r--r-- | src/Utility/Notify/Posix.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Utility/Notify/Posix.hs b/src/Utility/Notify/Posix.hs index 16b42ed..b802356 100644 --- a/src/Utility/Notify/Posix.hs +++ b/src/Utility/Notify/Posix.hs @@ -44,11 +44,11 @@ import Data.List.Split (splitOn) import Types.Reminder sendNotifications :: [Reminder] -> IO () -sendNotifications rems = do - maybeClient <- getDBusUserAddress - let client = undefined - - mapM_ (sendNotification client) rems +sendNotifications rems = + getDBusUserAddress >>= + maybe (return ()) (\address -> do + client <- connect address + mapM_ (sendNotification client) rems) sendNotification :: Client -> Reminder -> IO Notification sendNotification c rem = do @@ -70,8 +70,11 @@ getDBusUserAddress = do -- socketFile <- return realContents -- >>= mapM (return . ((dir ++ "/") ++)) -- >>= newestFile - addr <- readFile socketFile + addr <- dropWhile (/= 'u') . head . filter findSocketLine . lines + <$> readFile socketFile return (return addr >>= parseAddress) + where + findSocketLine line = takeWhile (/= '=') line == "DBUS_SESSION_BUS_ADDRESS" -- | Return the full path to the newest file in a directory, or the -- empty string if passed a file or empty directory or a path that |