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 | |
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
-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` |