diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Config.hs | 6 | ||||
| -rw-r--r-- | src/Main.hs | 5 | ||||
| -rw-r--r-- | src/Parsers.hs | 7 | ||||
| -rw-r--r-- | src/Window.hs | 20 | ||||
| -rw-r--r-- | src/Xmobar.hs | 3 | 
5 files changed, 25 insertions, 16 deletions
| diff --git a/src/Config.hs b/src/Config.hs index eaf044a..ed3e51a 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -58,6 +58,9 @@ data Config =             , allDesktops :: Bool    -- ^ Tell the WM to map to all desktops             , overrideRedirect :: Bool -- ^ Needed for dock behaviour in some                                        --   non-tiling WMs +           , pickBroadest :: Bool   -- ^ Use the broadest display +                                    --   instead of the first one by +                                    --   default             , lowerOnStart :: Bool   -- ^ lower to the bottom of the                                      --   window stack on initialization             , persistent :: Bool     -- ^ Whether automatic hiding should @@ -70,7 +73,7 @@ data Config =                                      --   commands in the output template                                      --   (default '%')             , alignSep :: String     -- ^ Separators for left, center and -                                    -- right text alignment +                                    --   right text alignment             , template :: String     -- ^ The output template             } deriving (Read) @@ -111,6 +114,7 @@ defaultConfig =             , persistent = False             , allDesktops = True             , overrideRedirect = True +           , pickBroadest = False             , commands = [ Run $ Date "%a %b %_d %Y * %H:%M:%S" "theDate" 10                          , Run StdinReader]             , sepChar = "%" diff --git a/src/Main.hs b/src/Main.hs index a3c60c3..92573b9 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -175,7 +175,7 @@ usage = usageInfo header options ++ footer  info :: String  info = "xmobar " ++ showVersion version          ++ "\n (C) 2007 - 2010 Andrea Rossato " -        ++ "\n (C) 2010 - 2013 Jose A Ortega Ruiz\n " +        ++ "\n (C) 2010 - 2014 Jose A Ortega Ruiz\n "          ++ mail ++ "\n" ++ license  mail :: String @@ -188,7 +188,7 @@ license = "\nThis program is distributed in the hope that it will be useful," ++            "\nSee the License for more details."  doOpts :: Config -> [Opts] -> IO Config -doOpts conf [] =  +doOpts conf [] =    return (conf {lowerOnStart = lowerOnStart conf && overrideRedirect conf})  doOpts conf (o:oo) =    case o of @@ -217,4 +217,3 @@ doOpts conf (o:oo) =                          "specified with the -" ++ c:" option\n")          readStr str = [x | (x,t) <- reads str, ("","") <- lex t]          doOpts' opts = doOpts opts oo - diff --git a/src/Parsers.hs b/src/Parsers.hs index a1d60d8..f25fd4d 100644 --- a/src/Parsers.hs +++ b/src/Parsers.hs @@ -175,12 +175,14 @@ parseConfig = runParser parseConf fields "Config" . stripComments        perms = permute $ Config                <$?> pFont <|?> pBgColor <|?> pFgColor <|?> pPosition                <|?> pBorder <|?> pBdColor <|?> pHideOnStart <|?> pAllDesktops -              <|?> pOverrideRedirect <|?> pLowerOnStart <|?> pPersistent +              <|?> pOverrideRedirect <|?> pPickBroadest +              <|?> pLowerOnStart <|?> pPersistent                <|?> pCommands <|?> pSepChar <|?> pAlignSep <|?> pTemplate +        fields    = [ "font", "bgColor", "fgColor", "sepChar", "alignSep"                    , "border", "borderColor" ,"template", "position" -                  , "allDesktops", "overrideRedirect" +                  , "allDesktops", "overrideRedirect", "pickBroadest"                    , "hideOnStart", "lowerOnStart", "persistent", "commands"                    ] @@ -199,6 +201,7 @@ parseConfig = runParser parseConf fields "Config" . stripComments        pBorder = readField border "border"        pAllDesktops = readField allDesktops "allDesktops"        pOverrideRedirect = readField overrideRedirect "overrideRedirect" +      pPickBroadest = readField pickBroadest "pickBroadest"        pCommands = field commands "commands" readCommands diff --git a/src/Window.hs b/src/Window.hs index 3fdb923..876b7a2 100644 --- a/src/Window.hs +++ b/src/Window.hs @@ -1,7 +1,7 @@  -----------------------------------------------------------------------------  -- |  -- Module      :  Window --- Copyright   :  (c) 2011-13 Jose A. Ortega Ruiz +-- Copyright   :  (c) 2011-14 Jose A. Ortega Ruiz  --             :  (c) 2012 Jochen Keil  -- License     :  BSD-style (see LICENSE)  -- @@ -40,7 +40,7 @@ createWin d fs c = do    rootw <- rootWindow d dflt    (as,ds) <- textExtents fs "0"    let ht = as + ds + 4 -      r = setPosition (position c) srs (fi ht) +      r = setPosition c (position c) srs (fi ht)    win <- newWindow  d (defaultScreenOfDisplay d) rootw r (overrideRedirect c)    setProperties c d win    setStruts r c d win srs @@ -54,13 +54,13 @@ repositionWin d win fs c = do    srs <- getScreenInfo d    (as,ds) <- textExtents fs "0"    let ht = as + ds + 4 -      r = setPosition (position c) srs (fi ht) +      r = setPosition c (position c) srs (fi ht)    moveResizeWindow d win (rect_x r) (rect_y r) (rect_width r) (rect_height r)    setStruts r c d win srs    return r -setPosition :: XPosition -> [Rectangle] -> Dimension -> Rectangle -setPosition p rs ht = +setPosition :: Config -> XPosition -> [Rectangle] -> Dimension -> Rectangle +setPosition c p rs ht =    case p' of      Top -> Rectangle rx ry rw h      TopP l r -> Rectangle (rx + fi l) ry (rw - fi l - fi r) h @@ -71,11 +71,11 @@ setPosition p rs ht =      BottomP l r -> Rectangle (rx + fi l) ny (rw - fi l - fi r) h      BottomSize a i ch  -> Rectangle (ax a i) (ny' ch) (nw i) (mh ch)      Static cx cy cw ch -> Rectangle (fi cx) (fi cy) (fi cw) (fi ch) -    OnScreen _ p'' -> setPosition p'' [scr] ht +    OnScreen _ p'' -> setPosition c p'' [scr] ht    where      (scr@(Rectangle rx ry rw rh), p') = -      case p of OnScreen i x -> (fromMaybe (broadest rs) $ safeIndex i rs, x) -                _ -> (broadest rs, p) +      case p of OnScreen i x -> (fromMaybe (picker rs) $ safeIndex i rs, x) +                _ -> (picker rs, p)      ny = ry + fi (rh - ht)      center i = rx + fi (div (remwid i) 2)      right  i = rx + fi (remwid i) @@ -89,7 +89,9 @@ setPosition p rs ht =      mh h' = max (fi h') h      ny' h' = ry + fi (rh - mh h')      safeIndex i = lookup i . zip [0..] -    broadest = maximumBy (compare `on` rect_width) +    picker = if pickBroadest c +             then maximumBy (compare `on` rect_width) +             else head  setProperties :: Config -> Display -> Window -> IO ()  setProperties c d w = do diff --git a/src/Xmobar.hs b/src/Xmobar.hs index ce32a0a..c126b7c 100644 --- a/src/Xmobar.hs +++ b/src/Xmobar.hs @@ -237,7 +237,8 @@ startCommand sig (com,s,ss)                             return (Just h,var)      where is = s ++ "Updating..." ++ ss -updateString :: Config -> TVar [String] -> IO [[(Widget, String, Maybe [Action])]] +updateString :: Config -> TVar [String] -> +                IO [[(Widget, String, Maybe [Action])]]  updateString conf v = do    s <- atomically $ readTVar v    let l:c:r:_ = s ++ repeat "" | 
