summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-02-20 01:23:25 +0100
committerJose A Ortega Ruiz <jao@gnu.org>2010-02-20 01:23:25 +0100
commit7f9eb02f5c420d8f9e425310d3982145649dbba1 (patch)
treefc75e488ff94ae8cf568d0bc9a0ba93b4db96678
parentf3f5a047efe49530fa730912c8f80d4c57b53347 (diff)
downloadxmobar-7f9eb02f5c420d8f9e425310d3982145649dbba1.tar.gz
xmobar-7f9eb02f5c420d8f9e425310d3982145649dbba1.tar.bz2
Using ByteStrings to more resilient MBox counting
Ignore-this: 3fd6e381a8c2810f330131491d03afef darcs-hash:20100220002325-748be-6fdb04d60e7a7e5d8c6fe7cd5af4c5e7c2fd7cf4.gz
-rw-r--r--Plugins/MBox.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/Plugins/MBox.hs b/Plugins/MBox.hs
index 8ca0e76..3f7b70c 100644
--- a/Plugins/MBox.hs
+++ b/Plugins/MBox.hs
@@ -25,7 +25,7 @@ import System.Directory
import System.FilePath
import System.INotify
-import Data.List (isPrefixOf)
+import qualified Data.ByteString.Lazy.Char8 as B
-- | A list of display names, paths to mbox files and display colours,
-- followed by a directory to resolve relative path names (can be "")
@@ -63,8 +63,9 @@ showC m n c =
countMails :: FilePath -> IO Int
countMails f =
handle ((\_ -> evaluate 0) :: SomeException -> IO Int)
- (do txt <- readFileSafe f
- evaluate $! length . filter (isPrefixOf "From ") . lines $ txt)
+ (do txt <- B.readFile f
+ evaluate $! length . filter (B.isPrefixOf from) . B.lines $ txt)
+ where from = B.pack "From "
handleNotification :: TVar (FilePath, Int) -> Event -> IO ()
handleNotification v _ = do