summaryrefslogtreecommitdiff
path: root/Presence/ConsoleWriter.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Presence/ConsoleWriter.hs')
-rw-r--r--Presence/ConsoleWriter.hs23
1 files changed, 15 insertions, 8 deletions
diff --git a/Presence/ConsoleWriter.hs b/Presence/ConsoleWriter.hs
index 6b611e68..7c377d83 100644
--- a/Presence/ConsoleWriter.hs
+++ b/Presence/ConsoleWriter.hs
@@ -23,6 +23,7 @@ import System.Posix.Process ( forkProcess, exitImmediately, executeFile )
23import System.Posix.User ( setUserID, getUserEntryForName, userID ) 23import System.Posix.User ( setUserID, getUserEntryForName, userID )
24import System.Posix.Files ( getFileStatus, fileMode ) 24import System.Posix.Files ( getFileStatus, fileMode )
25import System.INotify ( initINotify, EventVariety(Modify), addWatch ) 25import System.INotify ( initINotify, EventVariety(Modify), addWatch )
26import System.IO.Error
26import Data.Word ( Word8 ) 27import Data.Word ( Word8 )
27import Data.Text ( Text ) 28import Data.Text ( Text )
28import Data.Map ( Map ) 29import Data.Map ( Map )
@@ -34,6 +35,7 @@ import qualified Data.Text as Text
34-- import qualified Data.Text.IO as Text 35-- import qualified Data.Text.IO as Text
35import qualified Network.BSD as BSD 36import qualified Network.BSD as BSD
36 37
38import DPut
37import UTmp ( users2, utmp_file, UtmpRecord(..), UT_Type(..) ) 39import UTmp ( users2, utmp_file, UtmpRecord(..), UT_Type(..) )
38import FGConsole ( forkTTYMonitor ) 40import FGConsole ( forkTTYMonitor )
39import XMPPServer ( Stanza, makePresenceStanza, JabberShow(..), stanzaType 41import XMPPServer ( Stanza, makePresenceStanza, JabberShow(..), stanzaType
@@ -256,14 +258,19 @@ deliverGUIMessage cw tty utmp msg = do
256 Nothing -> t 258 Nothing -> t
257 putStrLn $ "deliverGUI: " ++ text 259 putStrLn $ "deliverGUI: " ++ text
258 handleIO_ (return False) $ do 260 handleIO_ (return False) $ do
259 uentry <- getUserEntryForName (Text.unpack $ utmpUser utmp) 261 muentry <- fmap Just (getUserEntryForName (Text.unpack $ utmpUser utmp))
260 let display = Text.unpack $ utmpHost utmp 262 `catchIOError` \e -> do
261 pid <- forkProcess $ do 263 dput XJabber $ "deliverGUIMessage(getUserEntryForName "++show (utmpUser utmp)++"): "++show e
262 setUserID (userID uentry) 264 return Nothing
263 setEnv "DISPLAY" display True 265 forM_ muentry $ \uentry -> do
264 -- rawSystem "/usr/bin/notify-send" [text] 266 let display = Text.unpack $ utmpHost utmp
265 executeFile "/usr/bin/notify-send" False [text] (Just [("DISPLAY",display)]) 267 pid <- forkProcess $ do
266 exitImmediately ExitSuccess 268 setUserID (userID uentry)
269 setEnv "DISPLAY" display True
270 -- rawSystem "/usr/bin/notify-send" [text]
271 executeFile "/usr/bin/notify-send" False [text] (Just [("DISPLAY",display)])
272 exitImmediately ExitSuccess
273 return ()
267 return True 274 return True
268 275
269crlf :: Text -> Text 276crlf :: Text -> Text