diff options
| author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-11 20:36:40 +0100 | 
|---|---|---|
| committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-11 20:36:40 +0100 | 
| commit | 1ec32c8454672a058ce60c2cc13f2fec6b08dd02 (patch) | |
| tree | 7998a2f78f01172d37e8e6fd3e4e88319819ed98 /Plugins | |
| parent | 699033f96984b23855257566477f211cd49b1182 (diff) | |
| parent | 39d76760bb31c4f3bb2db9808275b8ba32f81411 (diff) | |
| download | xmobar-1ec32c8454672a058ce60c2cc13f2fec6b08dd02.tar.gz xmobar-1ec32c8454672a058ce60c2cc13f2fec6b08dd02.tar.bz2  | |
Merge branch 'dev/tilde-support-for-paths' of https://github.com/mathstuf/xmobar into mathstuf-dev/tilde-support-for-paths
Diffstat (limited to 'Plugins')
| -rw-r--r-- | Plugins/Mail.hs | 8 | 
1 files changed, 7 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  | 
