diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2015-04-05 19:51:49 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2015-04-05 19:51:49 +0900 |
commit | ef6658144244e5dcb319a21cfc6dbe706c7ea0be (patch) | |
tree | 53a0bab45ef9ebf09f073b461cc68aa40747fc3e | |
parent | 330a4f9562f9e71ebf680451b8ed78790b103f30 (diff) | |
download | srem-ef6658144244e5dcb319a21cfc6dbe706c7ea0be.tar.gz |
discard SocketError when connecting to DBus
When srem is run by cron, dbus might not have started up yet. Don't
want an e-mail from cron every time this happens.
-rw-r--r-- | src/Utility/Notify/Posix.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Utility/Notify/Posix.hs b/src/Utility/Notify/Posix.hs index 3782405..5859b68 100644 --- a/src/Utility/Notify/Posix.hs +++ b/src/Utility/Notify/Posix.hs @@ -24,13 +24,13 @@ module Utility.Notify.Posix (sendNotifications) where import Control.Applicative (pure, (<$>), (<*>)) -import Control.Exception (catch) +import Control.Exception (try) import Control.Monad (filterM, foldM, liftM, mapM) import Data.Function (on) import Data.List (sortBy) import Data.Time.Clock (UTCTime) -import System.Directory (getDirectoryContents, getHomeDirectory, - getModificationTime, doesDirectoryExist) +import System.Directory (doesDirectoryExist, getDirectoryContents, + getHomeDirectory, getModificationTime) import System.Environment (getEnvironment, setEnv) import System.FilePath ((</>)) import System.Process (readProcessWithExitCode) @@ -38,6 +38,7 @@ import System.Process (readProcessWithExitCode) import DBus (Address, parseAddress) import DBus.Client (Client, ClientError, connect) import DBus.Notify +import DBus.Socket (SocketError) import qualified Control.SremConfig as SremConfig import Data.List.Split (splitOn) @@ -47,8 +48,8 @@ sendNotifications :: [Reminder] -> IO () sendNotifications rems = getDBusUserAddress >>= maybe (return ()) (\address -> do - client <- connect address - mapM_ (sendNotification client) rems) + maybeClient <- (try $ connect address) :: IO (Either SocketError Client) + either (\_ -> return ()) (\client -> mapM_ (sendNotification client) rems) maybeClient) sendNotification :: Client -> Reminder -> IO () sendNotification c rem = do |