From 8f449586fcfc8f70603cf7017cf38d3d03e58d31 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Tue, 24 Jul 2007 14:51:20 +0200 Subject: if an invalid color name or value is given the black pixel will used instead darcs-hash:20070724125120-d6583-c56837a2e85eb505ce2cc7d9462d5f4471afa302.gz --- Xmobar.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Xmobar.hs') diff --git a/Xmobar.hs b/Xmobar.hs index 853017d..7142a8d 100644 --- a/Xmobar.hs +++ b/Xmobar.hs @@ -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 -- cgit v1.2.3