summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Mail.hs
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-11 21:41:08 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-11 21:41:08 +0100
commit4b26940ed310b9d7119eaf83c18526eb5ec38cd5 (patch)
tree2f9be0ff20806b9330d2125cbeae9afac5101cd3 /Plugins/Mail.hs
parent643b9235844d730aa9f0340da2a290a3c42bbccc (diff)
downloadxmobar-4b26940ed310b9d7119eaf83c18526eb5ec38cd5.tar.gz
xmobar-4b26940ed310b9d7119eaf83c18526eb5ec38cd5.tar.bz2
MBox: support for ~ paths and skipping non-existing mboxes
Diffstat (limited to 'Plugins/Mail.hs')
-rw-r--r--Plugins/Mail.hs16
1 files changed, 1 insertions, 15 deletions
diff --git a/Plugins/Mail.hs b/Plugins/Mail.hs
index 89cac30..38cdaae 100644
--- a/Plugins/Mail.hs
+++ b/Plugins/Mail.hs
@@ -16,12 +16,12 @@ module Plugins.Mail where
import Prelude hiding (catch)
import Plugins
+import Plugins.Utils (expandHome, changeLoop)
import Control.Monad
import Control.Concurrent.STM
import System.Directory
-import System.Environment
import System.FilePath
import System.INotify
@@ -58,10 +58,6 @@ instance Exec Mail where
modifyTVar :: TVar a -> (a -> a) -> STM ()
modifyTVar v f = readTVar v >>= writeTVar v . f
-expandHome :: FilePath -> IO FilePath
-expandHome ('~':'/':path) = fmap (</> path) (getEnv "HOME")
-expandHome p = return p
-
handle :: TVar (Set String) -> Event -> IO ()
handle v e = atomically $ modifyTVar v $ case e of
Created {} -> create
@@ -72,13 +68,3 @@ handle v e = atomically $ modifyTVar v $ case e of
where
delete = S.delete (filePath e)
create = S.insert (filePath e)
-
-changeLoop :: Eq a => STM a -> (a -> IO ()) -> IO ()
-changeLoop s f = atomically s >>= go
- where
- go old = do
- f old
- go =<< atomically (do
- new <- s
- guard (new /= old)
- return new)