diff options
author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-24 14:51:20 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-24 14:51:20 +0200 |
commit | 8f449586fcfc8f70603cf7017cf38d3d03e58d31 (patch) | |
tree | 69dd2a91b6f0488cd7e82d16192c395e6425e300 /Xmobar.hs | |
parent | d15ff11f7021777e30a9d41cac0850b794a3d7e9 (diff) | |
download | xmobar-8f449586fcfc8f70603cf7017cf38d3d03e58d31.tar.gz xmobar-8f449586fcfc8f70603cf7017cf38d3d03e58d31.tar.bz2 |
if an invalid color name or value is given the black pixel will used instead
darcs-hash:20070724125120-d6583-c56837a2e85eb505ce2cc7d9462d5f4471afa302.gz
Diffstat (limited to 'Xmobar.hs')
-rw-r--r-- | Xmobar.hs | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -255,9 +255,14 @@ mkUnmanagedWindow dpy scr rw x y w h = do Utilities, aka stollen without givin' credit stuff. -} --- | Get the Pixel value for a named color +-- | Get the Pixel value for a named color: if an invalid name is +-- given the black pixel will be returned. initColor :: Display -> String -> IO Pixel -initColor dpy c = (color_pixel . fst) `liftM` allocNamedColor dpy colormap c +initColor dpy c = + catch (initColor' dpy c) (const $ return $ blackPixel dpy (defaultScreen dpy)) + +initColor' :: Display -> String -> IO Pixel +initColor' dpy c = (color_pixel . fst) `liftM` allocNamedColor dpy colormap c where colormap = defaultColormap dpy (defaultScreen dpy) -- | Short-hand for lifting in the IO monad |