From 231f262ab4eeb9d25b86808c8d5cec9266dada3d Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 27 Apr 2013 20:49:07 +0200 Subject: New -d (--dock) command line switch --- news.md | 7 +++++-- readme.md | 1 + src/Main.hs | 18 ++++++++++++------ src/Window.hs | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/news.md b/news.md index 96e19f4..e5bb6a8 100644 --- a/news.md +++ b/news.md @@ -1,6 +1,6 @@ % xmobar - Release notes -## Version 0.17 +## Version 0.17 (April 28, 2013) _New features_ @@ -13,6 +13,8 @@ _New features_ - New `allDesktops` and `overrideRedirect` configuration options, providing dock behaviour in tiling WMs (when set to True and False respectively). Cf. discussion at [github #105]. + - Experimental `-d` (start as a dock) option, may address [github #67] + in some window managers. _Bug fixes_ @@ -20,8 +22,9 @@ _Bug fixes_ - Safer volume plugin (Dmitry Malikov). - Battery percentage capped at 100% (RJ Regenold). +[github #67]: https://github.com/jaor/xmobar/issues/77 [github #77]: https://github.com/jaor/xmobar/issues/77 -[github #77]: https://github.com/jaor/xmobar/issues/105 +[github #105]: https://github.com/jaor/xmobar/issues/105 ## Version 0.16 (Dec 3, 2012) diff --git a/readme.md b/readme.md index 2e2de05..013f9d6 100644 --- a/readme.md +++ b/readme.md @@ -322,6 +322,7 @@ xmobar --help): -F fg color --fgcolor=fg color The foreground color. Default grey -o --top Place xmobar at the top of the screen -b --bottom Place xmobar at the bottom of the screen + -d --dock Try to start xmobar as a dock -a alignsep --alignsep=alignsep Separators for left, center and right text alignment. Default: '}{' -s char --sepchar=char The character used to separate commands in diff --git a/src/Main.hs b/src/Main.hs index 30878d2..90cd842 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -45,12 +45,12 @@ import Signal (setupSignalHandler) main :: IO () main = do initThreads - d <- openDisplay "" - args <- getArgs + d <- openDisplay "" + args <- getArgs (o,file) <- getOpts args (c,defaultings) <- case file of [cfgfile] -> readConfig cfgfile - _ -> readDefaultConfig + _ -> readDefaultConfig unless (null defaultings) $ putStrLn $ "Fields missing from config defaulted: " ++ intercalate "," defaultings @@ -82,8 +82,8 @@ splitTemplate conf = readConfig :: FilePath -> IO (Config,[String]) readConfig f = do file <- io $ fileExist f - s <- io $ if file then readFileSafe f else error $ - f ++ ": file not found!\n" ++ usage + s <- io $ if file then readFileSafe f else error $ + f ++ ": file not found!\n" ++ usage either (\err -> error $ f ++ ": configuration file contains errors at:\n" ++ show err) return $ parseConfig s @@ -103,6 +103,7 @@ data Opts = Help | FgColor String | T | B + | D | AlignSep String | Commands String | AddCommand String @@ -123,6 +124,8 @@ options = , Option "o" ["top"] (NoArg T) "Place xmobar at the top of the screen" , Option "b" ["bottom"] (NoArg B) "Place xmobar at the bottom of the screen" + , Option "d" ["dock"] (NoArg D) + "Don't override redirect from WM and function as a dock" , Option "a" ["alignsep"] (ReqArg AlignSep "alignsep") "Separators for left, center and right text\nalignment. Default: '}{'" , Option "s" ["sepchar"] (ReqArg SepChar "char") @@ -165,7 +168,8 @@ 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 [] = return conf +doOpts conf [] = + return (conf {lowerOnStart = lowerOnStart conf && overrideRedirect conf}) doOpts conf (o:oo) = case o of Help -> putStr usage >> exitSuccess @@ -175,6 +179,7 @@ doOpts conf (o:oo) = FgColor s -> doOpts' (conf {fgColor = s}) T -> doOpts' (conf {position = Top}) B -> doOpts' (conf {position = Bottom}) + D -> doOpts' (conf {overrideRedirect = False}) AlignSep s -> doOpts' (conf {alignSep = s}) SepChar s -> doOpts' (conf {sepChar = s}) Template s -> doOpts' (conf {template = s}) @@ -192,3 +197,4 @@ 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/Window.hs b/src/Window.hs index 2fca3cb..8628435 100644 --- a/src/Window.hs +++ b/src/Window.hs @@ -40,7 +40,7 @@ createWin d fs c = do r = setPosition (position c) srs (fi ht) win <- newWindow d (defaultScreenOfDisplay d) rootw r (overrideRedirect c) when (lowerOnStart c) (lowerWindow d win) - unless (hideOnStart c) $ showWindow r c d win + unless (hideOnStart c) $ showWindow r c d win setProperties r c d win srs return (r,win) -- cgit v1.2.3