diff options
author | Alexander Shabalin <shabalyn.a@gmail.com> | 2014-09-14 14:28:26 +0400 |
---|---|---|
committer | Alexander Shabalin <shabalyn.a@gmail.com> | 2014-09-24 23:49:47 +0400 |
commit | 05554f239c79d738848f5453b16b8ad01e9a5f50 (patch) | |
tree | fba70a167596c7bbb8c668f9084e14e70b9ba1b7 /src/Bitmap.hs | |
parent | 2215d77ff8ffb55cfd0c098a017a86ecf0620b05 (diff) | |
download | xmobar-05554f239c79d738848f5453b16b8ad01e9a5f50.tar.gz xmobar-05554f239c79d738848f5453b16b8ad01e9a5f50.tar.bz2 |
Add iconRoot config option
For all <icon=path/> if path does not start with "/", "./", "../"
it will have iconRoot ++ "/" prepended to it.
Diffstat (limited to 'src/Bitmap.hs')
-rw-r--r-- | src/Bitmap.hs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Bitmap.hs b/src/Bitmap.hs index ff79262..63baf6a 100644 --- a/src/Bitmap.hs +++ b/src/Bitmap.hs @@ -23,6 +23,7 @@ import Control.Monad.Trans(MonadIO(..)) import Data.Map hiding (foldr, map, filter) import Graphics.X11.Xlib import System.Directory (doesFileExist) +import System.FilePath ((</>)) import System.Mem.Weak ( addFinalizer ) import ColorCache import Parsers (Widget(..)) @@ -41,15 +42,19 @@ data Bitmap = Bitmap { width :: Dimension , bitmapType :: BitmapType } -updateCache :: Display -> Window -> Map FilePath Bitmap -> +updateCache :: Display -> Window -> Map FilePath Bitmap -> FilePath -> [[(Widget, String, Maybe [Action])]] -> IO (Map FilePath Bitmap) -updateCache dpy win cache ps = do +updateCache dpy win cache iconRoot ps = do let paths = map (\(Icon p, _, _) -> p) . concatMap (filter icons) $ ps icons (Icon _, _, _) = True icons _ = False + expandPath path@('/':_) = path + expandPath path@('.':'/':_) = path + expandPath path@('.':'.':'/':_) = path + expandPath path = iconRoot </> path go m path = if member path m then return m - else do bitmap <- loadBitmap dpy win path + else do bitmap <- loadBitmap dpy win $ expandPath path return $ maybe m (\b -> insert path b m) bitmap foldM go cache paths |