diff options
-rw-r--r-- | Plugins/Mail.hs | 8 | ||||
-rw-r--r-- | README | 1 |
2 files changed, 8 insertions, 1 deletions
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 @@ -550,6 +550,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` |