From aa507d0bda3919e1885edb327b855908f2aafcb8 Mon Sep 17 00:00:00 2001 From: Jochen Keil Date: Wed, 8 Aug 2012 12:12:17 +0200 Subject: BufferedPipeReader: A plugin for temporary data display This plugin allows to display data from multiple pipes. New data will always overwrite the currently displayed data. However, if a timeout is specified, the previous content is restored. Configuration works like this: BufferedPipeReader [ ( Timeout, "/path/to/fifo/pipe" ), (..), .. ] If Timeout is set to 0 then the content is persistent, i.e. it will be reset to any previous value, it will itself become the previous value. If Timeout is set to a negative value the earth will stop spinning, so don't do it. --- src/Config.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Config.hs') diff --git a/src/Config.hs b/src/Config.hs index 4405314..712687d 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -28,6 +28,7 @@ import {-# SOURCE #-} Runnable import Plugins.Monitors import Plugins.Date import Plugins.PipeReader +import Plugins.BufferedPipeReader import Plugins.CommandReader import Plugins.StdinReader import Plugins.XMonadLog @@ -113,7 +114,7 @@ infixr :*: -- the 'Runnable.Runnable' Read instance. To install a plugin just add -- the plugin's type to the list of types (separated by ':*:') appearing in -- this function's type signature. -runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*: CommandReader :*: StdinReader :*: XMonadLog :*: EWMH :*: Kbd :*: +runnableTypes :: Command :*: Monitors :*: Date :*: PipeReader :*: BufferedPipeReader :*: CommandReader :*: StdinReader :*: XMonadLog :*: EWMH :*: Kbd :*: #ifdef INOTIFY Mail :*: MBox :*: #endif -- cgit v1.2.3 From 5074fdf2d6aa85ce17ad98112ec5019eb05a39c4 Mon Sep 17 00:00:00 2001 From: Jochen Keil Date: Fri, 10 Aug 2012 08:36:03 +0200 Subject: New configuration option "persistent" When persistent is set to True then xmobar will always be mapped (revealed) and never be hidden. The flag is checked in eventLoop and operation to map/unmap windows is not carried out if persistence is desired. --- src/Config.hs | 3 +++ src/Parsers.hs | 11 +++++++---- src/Xmobar.hs | 16 +++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src/Config.hs') diff --git a/src/Config.hs b/src/Config.hs index 712687d..47358b0 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -57,6 +57,8 @@ data Config = , borderColor :: String -- ^ Border color , lowerOnStart :: Bool -- ^ Lower to the bottom of the -- window stack on initialization + , persistent :: Bool -- ^ Whether automatic hiding should + -- be enabled or disabled , commands :: [Runnable] -- ^ For setting the command, the command arguments -- and refresh rate for the programs to run (optional) , sepChar :: String -- ^ The character to be used for indicating @@ -96,6 +98,7 @@ defaultConfig = , border = NoBorder , borderColor = "#BFBFBF" , lowerOnStart = True + , persistent = False , commands = [ Run $ Date "%a %b %_d %Y * %H:%M:%S" "theDate" 10 , Run StdinReader] , sepChar = "%" diff --git a/src/Parsers.hs b/src/Parsers.hs index f5f00a9..c92480e 100644 --- a/src/Parsers.hs +++ b/src/Parsers.hs @@ -131,13 +131,15 @@ parseConfig = runParser parseConf fields "Config" . stripComments <$?> pFont <|?> pBgColor <|?> pFgColor <|?> pPosition <|?> pBorder <|?> pBdColor - <|?> pLowerOnStart <|?> pCommands - <|?> pSepChar <|?> pAlignSep - <|?> pTemplate + <|?> pLowerOnStart <|?> pPersistent + <|?> pCommands <|?> pSepChar + <|?> pAlignSep <|?> pTemplate fields = [ "font", "bgColor", "fgColor", "sepChar", "alignSep" , "border", "borderColor" ,"template", "position" - , "lowerOnStart", "commands"] + , "lowerOnStart", "persistent", "commands" + ] + pFont = strField font "font" pBgColor = strField bgColor "bgColor" pFgColor = strField fgColor "fgColor" @@ -148,6 +150,7 @@ parseConfig = runParser parseConf fields "Config" . stripComments pPosition = field position "position" $ tillFieldEnd >>= read' "position" pLowerOnStart = field lowerOnStart "lowerOnStart" $ tillFieldEnd >>= read' "lowerOnStart" + pPersistent = field persistent "persistent" $ tillFieldEnd >>= read' "persistent" pBorder = field border "border" $ tillFieldEnd >>= read' "border" pCommands = field commands "commands" $ readCommands diff --git a/src/Xmobar.hs b/src/Xmobar.hs index a65a236..1ae55bb 100644 --- a/src/Xmobar.hs +++ b/src/Xmobar.hs @@ -145,11 +145,17 @@ eventLoop tv xc@(XConf d _ w fs cfg) signal = do Toggle -> toggle where - hide = hideWindow d w >> eventLoop tv xc signal - reveal = do - r' <- repositionWin d w fs cfg - showWindow d w - eventLoop tv (XConf d r' w fs cfg) signal + isPersistent = not $ persistent cfg + + hide = when isPersistent (hideWindow d w) >> eventLoop tv xc signal + + reveal = if isPersistent + then do + r' <- repositionWin d w fs cfg + showWindow d w + eventLoop tv (XConf d r' w fs cfg) signal + else eventLoop tv xc signal + toggle = isMapped d w >>= \b -> if b then hide else reveal reposWindow rcfg = do -- cgit v1.2.3