From baca50387a262e3476e94029232258e0d4591d27 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 5 Dec 2011 19:12:43 -0500 Subject: Allow incremental commands to be given Using the -C option, *additional* commands can be given to Xmobar. This allows a common configuration to be used and then differentiated in just the -C calls. --- src/Main.hs | 79 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 364fa02..38975bc 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -92,32 +92,34 @@ readDefaultConfig = do data Opts = Help | Version - | Font String - | BgColor String - | FgColor String + | Font String + | BgColor String + | FgColor String | T | B - | AlignSep String - | Commands String - | SepChar String - | Template String - | OnScr String + | AlignSep String + | Commands String + | AddCommand String + | SepChar String + | Template String + | OnScr String deriving Show options :: [OptDescr Opts] options = - [ Option ['h','?' ] ["help" ] (NoArg Help ) "This help" - , Option ['V' ] ["version" ] (NoArg Version ) "Show version information" - , Option ['f' ] ["font" ] (ReqArg Font "font name") "The font name" - , Option ['B' ] ["bgcolor" ] (ReqArg BgColor "bg color" ) "The background color. Default black" - , Option ['F' ] ["fgcolor" ] (ReqArg FgColor "fg color" ) "The foreground color. Default grey" - , 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 ['a' ] ["alignsep" ] (ReqArg AlignSep "alignsep" ) "Separators for left, center and right text\nalignment. Default: '}{'" - , Option ['s' ] ["sepchar" ] (ReqArg SepChar "char" ) "The character used to separate commands in\nthe output template. Default '%'" - , Option ['t' ] ["template" ] (ReqArg Template "template" ) "The output template" - , Option ['c' ] ["commands" ] (ReqArg Commands "commands" ) "The list of commands to be executed" - , Option ['x' ] ["screen" ] (ReqArg OnScr "screen" ) "On which X screen number to start" + [ Option ['h','?' ] ["help" ] (NoArg Help ) "This help" + , Option ['V' ] ["version" ] (NoArg Version ) "Show version information" + , Option ['f' ] ["font" ] (ReqArg Font "font name") "The font name" + , Option ['B' ] ["bgcolor" ] (ReqArg BgColor "bg color" ) "The background color. Default black" + , Option ['F' ] ["fgcolor" ] (ReqArg FgColor "fg color" ) "The foreground color. Default grey" + , 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 ['a' ] ["alignsep" ] (ReqArg AlignSep "alignsep" ) "Separators for left, center and right text\nalignment. Default: '}{'" + , Option ['s' ] ["sepchar" ] (ReqArg SepChar "char" ) "The character used to separate commands in\nthe output template. Default '%'" + , Option ['t' ] ["template" ] (ReqArg Template "template" ) "The output template" + , Option ['c' ] ["commands" ] (ReqArg Commands "commands" ) "The list of commands to be executed" + , Option ['C' ] ["add-command" ] (ReqArg AddCommand "command" ) "Add to the list of commands to be executed" + , Option ['x' ] ["screen" ] (ReqArg OnScr "screen" ) "On which X screen number to start" ] getOpts :: [String] -> IO ([Opts], [String]) @@ -150,23 +152,26 @@ doOpts :: Config -> [Opts] -> IO Config doOpts conf [] = return conf doOpts conf (o:oo) = case o of - Help -> putStr usage >> exitWith ExitSuccess - Version -> putStrLn info >> exitWith ExitSuccess - Font s -> doOpts (conf {font = s }) oo - BgColor s -> doOpts (conf {bgColor = s }) oo - FgColor s -> doOpts (conf {fgColor = s }) oo - T -> doOpts (conf {position = Top }) oo - B -> doOpts (conf {position = Bottom}) oo - AlignSep s -> doOpts (conf {alignSep = s }) oo - SepChar s -> doOpts (conf {sepChar = s }) oo - Template s -> doOpts (conf {template = s }) oo - OnScr n -> doOpts (conf {position = OnScreen (read n) $ position conf}) oo - Commands s -> case readCom s of - Right x -> doOpts (conf { commands = x }) oo - Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1) - where readCom str = + Help -> putStr usage >> exitWith ExitSuccess + Version -> putStrLn info >> exitWith ExitSuccess + Font s -> doOpts (conf {font = s }) oo + BgColor s -> doOpts (conf {bgColor = s }) oo + FgColor s -> doOpts (conf {fgColor = s }) oo + T -> doOpts (conf {position = Top }) oo + B -> doOpts (conf {position = Bottom}) oo + AlignSep s -> doOpts (conf {alignSep = s }) oo + SepChar s -> doOpts (conf {sepChar = s }) oo + Template s -> doOpts (conf {template = s }) oo + OnScr n -> doOpts (conf {position = OnScreen (read n) $ position conf}) oo + Commands s -> case readCom 'c' s of + Right x -> doOpts (conf { commands = x }) oo + Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1) + AddCommand s -> case readCom 'C' s of + Right x -> doOpts (conf { commands = commands conf ++ x }) oo + Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1) + where readCom c str = case readStr str of - [x] -> Right x - _ -> Left "xmobar: cannot read list of commands specified with the -c option\n" + [x] -> Right x + _ -> Left "xmobar: cannot read list of commands specified with the -" ++ c:" option\n" readStr str = [x | (x,t) <- reads str, ("","") <- lex t] -- cgit v1.2.3 From c0e28d9812633ec1734cd3be9832456260f04ea6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 5 Dec 2011 19:13:46 -0500 Subject: Allow XMonadLog to have a separate name as well --- src/Plugins/XMonadLog.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Plugins/XMonadLog.hs b/src/Plugins/XMonadLog.hs index 3461e26..1403800 100644 --- a/src/Plugins/XMonadLog.hs +++ b/src/Plugins/XMonadLog.hs @@ -30,17 +30,19 @@ import Foreign.C (CChar) import XUtil (nextEvent') -data XMonadLog = XMonadLog | XPropertyLog String +data XMonadLog = XMonadLog | XPropertyLog String | NamedXPropertyLog String String deriving (Read, Show) instance Exec XMonadLog where alias XMonadLog = "XMonadLog" alias (XPropertyLog atom) = atom + alias (NamedXPropertyLog _ name) = name start x cb = do let atom = case x of - XMonadLog -> "_XMONAD_LOG" - XPropertyLog a -> a + XMonadLog -> "_XMONAD_LOG" + XPropertyLog a -> a + NamedXPropertyLog a _ -> a d <- openDisplay "" xlog <- internAtom d atom False -- cgit v1.2.3 From fb1186dabda26a2eed55ec1e7bd2ff4b1a8f3e50 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 11 Mar 2012 13:55:34 -0400 Subject: Add parentheses --- src/Main.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Main.hs b/src/Main.hs index 38975bc..4c3f351 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -172,6 +172,6 @@ doOpts conf (o:oo) = where readCom c str = case readStr str of [x] -> Right x - _ -> Left "xmobar: cannot read list of commands specified with the -" ++ c:" option\n" + _ -> Left ("xmobar: cannot read list of commands specified with the -" ++ c:" option\n") readStr str = [x | (x,t) <- reads str, ("","") <- lex t] -- cgit v1.2.3 From 23094dce7d900ed1ac331631a9a3df6470f8803a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 12 Mar 2012 05:54:16 -0400 Subject: Update --help output in README --- README | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/README b/README index 8879356..dc72b6b 100644 --- a/README +++ b/README @@ -271,20 +271,22 @@ xmobar --help): Usage: xmobar [OPTION...] [FILE] Options: - -h, -? --help This help - -V --version Show version information - -f font name --font=font name The font name - -B bg color --bgcolor=bg color The background color. Default black - -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 - -a alignsep --alignsep=alignsep Separators for left, center and right text - alignment. Default: '}{' - -s char --sepchar=char The character used to separate commands in - the output template. Default '%' - -t template --template=template The output template - -c commands --commands=commands The list of commands to be executed - -x screen --screen=screen On which X screen number to start + -h, -? --help This help + -V --version Show version information + -f font name --font=font name The font name + -B bg color --bgcolor=bg color The background color. Default black + -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 + -a alignsep --alignsep=alignsep Separators for left, center and right text + alignment. Default: '}{' + -s char --sepchar=char The character used to separate commands in + the output template. Default '%' + -t template --template=template The output template + -c commands --commands=commands The list of commands to be executed + -C command --add-command=command Add to the list of commands to be executed + -x screen --screen=screen On which X screen number to start + Mail bug reports and suggestions to ## The Output Template -- cgit v1.2.3 From 61c5e62376cce56247e1e709ed41896a014b7b69 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 12 Mar 2012 05:54:25 -0400 Subject: Add NamedXPropertyLog documentation --- README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README b/README index dc72b6b..b340d30 100644 --- a/README +++ b/README @@ -706,6 +706,10 @@ Monitors have default aliases. [samples/xmonadpropwrite.hs script]: https://github.com/jaor/xmobar/raw/master/samples/xmonadpropwrite.hs +`NamedXPropertyLog PropName Alias` + +- Same as XPropertyLog, but a custom alias can be specified. + `Brightness Args RefreshRate` - Aliases to `bright` -- cgit v1.2.3