From f61136d9649555c155bd5b3f570bf1269b98bc9a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 11 Dec 2010 14:11:09 -0500 Subject: Expand '~' in paths for mail directories --- Plugins/Mail.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugins/Mail.hs b/Plugins/Mail.hs index 851fc5e..165467a 100644 --- a/Plugins/Mail.hs +++ b/Plugins/Mail.hs @@ -21,6 +21,7 @@ import Control.Monad import Control.Concurrent.STM import System.Directory +import System.Environment import System.FilePath import System.INotify @@ -37,9 +38,10 @@ instance Exec Mail where vs <- mapM (const $ newTVarIO S.empty) ms let ts = map fst ms - ds = map (( "new") . snd) ms + rs = map (( "new") . snd) ms ev = [Move, MoveIn, MoveOut, Create, Delete] + ds <- mapM expandHome rs i <- initINotify zipWithM_ (\d v -> addWatch i ev d (handle v)) ds vs @@ -56,6 +58,10 @@ instance Exec Mail where modifyTVar :: TVar a -> (a -> a) -> STM () modifyTVar v f = readTVar v >>= writeTVar v . f +expandHome :: FilePath -> IO FilePath +expandHome ('~':'/':path) = getEnv "HOME" >>= return . flip () path +expandHome p = return p + handle :: TVar (Set String) -> Event -> IO () handle v e = atomically $ modifyTVar v $ case e of Created {} -> create -- cgit v1.2.3 From 39d76760bb31c4f3bb2db9808275b8ba32f81411 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sat, 11 Dec 2010 14:17:53 -0500 Subject: Add documentation for ~ support in Mail --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 9a7f92b..e797f3a 100644 --- a/README +++ b/README @@ -547,6 +547,7 @@ Monitors have default aliases. - This plugin requires inotify support in your linux kernel and the [hinotify] package. To activate, pass `--flags="with_inotify"` during compilation. +- Paths may start with a '~' to expand to the user's home directory. `MBox Mboxes Opts Alias` -- cgit v1.2.3