diff options
author | Mark Wright <gienah@gentoo.org> | 2018-04-24 20:02:04 +1000 |
---|---|---|
committer | Mark Wright <gienah@gentoo.org> | 2018-04-24 20:02:04 +1000 |
commit | fb0a23f395445540f865ae00b33e75e0175db4ef (patch) | |
tree | c860094f5cc4c686f6a8d6dc1d643652ee388b86 /src/Plugins | |
parent | f897fbe3645d5af96197ee6b9c2dc547f5c036cf (diff) | |
download | xmobar-fb0a23f395445540f865ae00b33e75e0175db4ef.tar.gz xmobar-fb0a23f395445540f865ae00b33e75e0175db4ef.tar.bz2 |
Build with hinotify 0.3.10 and earlier, fixes #348, fixes #350
Diffstat (limited to 'src/Plugins')
-rw-r--r-- | src/Plugins/MBox.hs | 11 | ||||
-rw-r--r-- | src/Plugins/Mail.hs | 19 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/Plugins/MBox.hs b/src/Plugins/MBox.hs index 62f9d78..48a6228 100644 --- a/src/Plugins/MBox.hs +++ b/src/Plugins/MBox.hs @@ -31,6 +31,15 @@ import System.INotify (Event(..), EventVariety(..), initINotify, addWatch) import qualified Data.ByteString.Lazy.Char8 as B +#if MIN_VERSION_hinotify(0,3,10) +import qualified Data.ByteString.Char8 as BS (ByteString, pack) +pack :: String -> BS.ByteString +pack = BS.pack +#else +pack :: String -> String +pack = id +#endif + data Options = Options { oAll :: Bool , oUniq :: Bool @@ -93,7 +102,7 @@ instance Exec MBox where n <- if exists then countMails f else return (-1) v <- newTVarIO (f, n) when exists $ - addWatch i events f (handleNotification v) >> return () + addWatch i events (pack f) (handleNotification v) >> return () return v) boxes diff --git a/src/Plugins/Mail.hs b/src/Plugins/Mail.hs index 772d1d7..538bcf7 100644 --- a/src/Plugins/Mail.hs +++ b/src/Plugins/Mail.hs @@ -29,6 +29,19 @@ import System.INotify import Data.List (isPrefixOf) import Data.Set (Set) import qualified Data.Set as S + +#if MIN_VERSION_hinotify(0,3,10) +import qualified Data.ByteString.Char8 as BS (ByteString, pack, unpack) +unpack :: BS.ByteString -> String +unpack = BS.unpack +pack :: String -> BS.ByteString +pack = BS.pack +#else +unpack :: String -> String +unpack = id +pack :: String -> String +pack = id +#endif #else import System.IO #endif @@ -54,7 +67,7 @@ instance Exec Mail where ds <- mapM expandHome rs i <- initINotify - zipWithM_ (\d v -> addWatch i ev d (handle v)) ds vs + zipWithM_ (\d v -> addWatch i ev d (handle v)) (map pack ds) vs forM_ (zip ds vs) $ \(d, v) -> do s <- fmap (S.fromList . filter (not . isPrefixOf ".")) @@ -74,6 +87,6 @@ handle v e = atomically $ modifyTVar v $ case e of MovedOut {} -> delete _ -> id where - delete = S.delete (filePath e) - create = S.insert (filePath e) + delete = S.delete ((unpack . filePath) e) + create = S.insert ((unpack . filePath) e) #endif |