diff options
Diffstat (limited to 'Presence/ConsoleWriter.hs')
-rw-r--r-- | Presence/ConsoleWriter.hs | 23 |
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 ) | |||
23 | import System.Posix.User ( setUserID, getUserEntryForName, userID ) | 23 | import System.Posix.User ( setUserID, getUserEntryForName, userID ) |
24 | import System.Posix.Files ( getFileStatus, fileMode ) | 24 | import System.Posix.Files ( getFileStatus, fileMode ) |
25 | import System.INotify ( initINotify, EventVariety(Modify), addWatch ) | 25 | import System.INotify ( initINotify, EventVariety(Modify), addWatch ) |
26 | import System.IO.Error | ||
26 | import Data.Word ( Word8 ) | 27 | import Data.Word ( Word8 ) |
27 | import Data.Text ( Text ) | 28 | import Data.Text ( Text ) |
28 | import Data.Map ( Map ) | 29 | import 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 |
35 | import qualified Network.BSD as BSD | 36 | import qualified Network.BSD as BSD |
36 | 37 | ||
38 | import DPut | ||
37 | import UTmp ( users2, utmp_file, UtmpRecord(..), UT_Type(..) ) | 39 | import UTmp ( users2, utmp_file, UtmpRecord(..), UT_Type(..) ) |
38 | import FGConsole ( forkTTYMonitor ) | 40 | import FGConsole ( forkTTYMonitor ) |
39 | import XMPPServer ( Stanza, makePresenceStanza, JabberShow(..), stanzaType | 41 | import 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 | ||
269 | crlf :: Text -> Text | 276 | crlf :: Text -> Text |