packages feed

xmobar 0.18 → 0.19

raw patch · 20 files changed

+249/−110 lines, 20 files

Files

news.md view
@@ -1,5 +1,48 @@ % xmobar - Release notes +## Version 0.19 (October 27, 2013)++As of this release, the old bug tracker at Google code is deprecated.+Please use [Github's tracker] for new bugs.++_New features_++  - New monitor `BatteryN`, a variant of `BatteryP` that lets you+    specify the name of the monitor in the template.+  - Support for configuration file living in `XDG_CONFIG_HOME` (see+    [github #99]).+  - `Com` uses safer `runInteractiveProcess` instead of spawning a+    shell (David McLean).  If you're using shell expansion in your+    `Com` (e.g. "~/bin/script") here's a workaround: `Run Com+    "/bin/bash" ["-c", "~/bin/script"]` (cf. [github #127]).+  - New plugin `UnsafeStdinReader` that allows actions from stdin.+    Now it's possible to have clickable workspaces!+    (Thiago Negri, see [github #125]).+  - New monitor configuration option (`-x` or `--nastring`) that allows+    specifying what string to display when a monitor is not available+    (defaulting to "N/A"). Cf. [github #119].++_Bug fixes_++  - Using the width options `-w`, `-m` and `-M` in battery monitors+    watts display ([github #118]).+  - Using the `-d` option in `CoreTemp` ([github #115])+  - Fix for systems not supporting PCRE regular expressions: we use+    now BCEs, so regex-compat should be enough everywhere (see+    [github #117]).+  - Weather monitor: support for stations without name (Sergei+    Trofimovich, [issue #65]).++[Github's tracker]: https://github.com/jaor/xmobar/issues+[github #99]: https://github.com/jaor/xmobar/issues/115+[github #115]: https://github.com/jaor/xmobar/issues/115+[github #117]: https://github.com/jaor/xmobar/issues/117+[github #125]: https://github.com/jaor/xmobar/issues/125+[issue #65]: http://code.google.com/p/xmobar/issues/detail?id=65+[github #118]: https://github.com/jaor/xmobar/issues/118+[github #119]: https://github.com/jaor/xmobar/issues/119+[github #127]: https://github.com/jaor/xmobar/issues/127+ ## Version 0.18 (June 5, 2013)  _New features_
readme.md view
@@ -1,4 +1,4 @@-% xmobar - A Minimalistic Text Based Status Bar+% xmobar - a minimalistic status bar  About =====@@ -11,7 +11,7 @@ features, like dynamic color management, icons, output templates, and extensibility through plugins. -This page documents xmobar 0.18 (see [release notes]).+This page documents xmobar 0.19 (see [release notes]).  [This screenshot] shows xmobar running under [sawfish], with antialiased fonts. And [this one] is my desktop with [xmonad] and two@@ -26,11 +26,14 @@ Bug Reports =========== -To submit bug reports you can use the [bug tracker over at Google-code] or send mail to our [Mailing list].+To submit bug reports you can use the [bug tracker over at Github] or+send mail to our [Mailing list]. -[bug tracker over at Google code]: http://code.google.com/p/xmobar/issues+Note: the old bug tracker at Google code is deprecated.  Please use+Github's for new bugs. +[bug tracker over at Github]: https://github.com/jaor/xmobar/issues+ Installation ============ @@ -141,7 +144,9 @@  `with_alsa` :    Support for ALSA sound cards. Enables the Volume plugin. Requires the-     [alsa-mixer] package.+     [alsa-mixer] package.  To install the latter, you'll need the+     [libasound] C library and headers in your system (e.g., install+     `libasound2-dev` in Debian-based systems).  `with_datezone` :    Support for other timezones. Enables the DateZone plugin.@@ -161,9 +166,11 @@          xmobar & -if you have the default configuration file saved as `~/.xmobarrc`+if you have the default configuration file saved as+`$XDG\_CONFIG\_HOME/xmobar/xmobarrc` (defaulting to+`~/.config/xmobar/xmobarrc`), or `~/.xmobarrc`. -### Signal Handling+## Signal Handling  Since 0.14 xmobar reacts to SIGUSR1 and SIGUSR2: @@ -609,6 +616,10 @@     - Total number of characters used to draw bars.     - Long option: `--bwidth`     - Default value: 10+- `-x` _string_ N/A string+    - String to be used when the monitor is not available+    - Long option: `--nastring`+    - Default value: "N/A"  Commands' arguments must be set as a list. E.g.: @@ -671,7 +682,7 @@  ### `Wireless Interface Args RefreshRate` -- Aliases to the interface name with the suffix "wi": thus, `Wirelss+- Aliases to the interface name with the suffix "wi": thus, `Wireless   "wlan0" []` can be used as `%wlan0wi%` - Args: default monitor arguments - Variables that can be used with the `-t`/`--template` argument:@@ -778,7 +789,12 @@ - The "idle" AC state is selected whenever the AC power entering the   battery is zero. +### `BatteryN Dirs Args RefreshRate Alias` +Works like `BatteryP`, but lets you specify an alias for the monitor+other than "battery".  Useful in case you one separate monitors for+more than one battery.+ ### `TopProc Args RefreshRate`  - Aliases to `top`@@ -1101,18 +1117,35 @@  ## Other Plugins -`StdinReader`+<font size="+1">**`StdinReader`**</font>  - Aliases to StdinReader - Displays any text received by xmobar on its standard input.+- Strips actions from the text received.  This means you can't pass dynamic+  actions via stdin.  This is safer than `UnsafeStdinReader` because there is+  no need to escape the content before passing it to xmobar's standard input. -`Date Format Alias RefreshRate`+<font size="+1">**`UnsafeStdinReader`**</font> +- Aliases to UnsafeStdinReader+- Displays any text received by xmobar on its standard input.+- Will not do anything to the text received.  This means you can pass dynamic+  actions via stdin.  Be careful to remove tags from dynamic text that you+  pipe-thru to xmobar's standard input, e.g. window's title.  There is no way+  to escape the tags, i.e. you can't print a literal `<action>` tag as a text+  on xmobar.+- Sample usage: send to xmobar's stdin the list of your workspaces enclosed by+  actions tags that switches the workspaces to be able to switch workspaces by+  clicking on xmobar:+  `<action=xdotool key alt+1>ws1</action> <action=xdotool key alt+1>ws2</action>`++<font size="+1">**`Date Format Alias RefreshRate`**</font>+ - Format is a time format string, as accepted by the standard ISO C   `strftime` function (or Haskell's `formatCalendarTime`). - Sample usage: `Run Date "%a %b %_d %Y <fc=#ee9a00>%H:%M:%S</fc>" "date" 10` -`DateZone Format Locale Zone Alias RefreshRate`+<font size="+1">**`DateZone Format Locale Zone Alias RefreshRate`**</font>  - Format is a time format string, as accepted by the standard ISO C   `strftime` function (or Haskell's `formatCalendarTime`).@@ -1125,45 +1158,49 @@ - Sample usage:   `Run DateZone "%a %H:%M:%S" "de_DE.UTF-8" "Europe/Vienna" "viennaTime" 10` -`CommandReader "/path/to/program" Alias`+<font size="+1">**`CommandReader "/path/to/program" Alias`**</font>  - Runs the given program, and displays its standard output. -`PipeReader "default text:/path/to/pipe" Alias`+<font size="+1">**`PipeReader "default text:/path/to/pipe" Alias`**</font>  - Reads its displayed output from the given pipe. - Prefix an optional default text separated by a colon -`BufferedPipeReader  Alias [ (Timeout, Bool, "/path/to/pipe1")-                           , (Timeout, Bool, "/path/to/pipe2")-                           , ..-                           ]`+<font size="+1">+**`BufferedPipeReader Alias [(Timeout, Bool, "/path/to/pipe1"), ..]`**+</font>  - Display data from multiple pipes.-- Timeout (in tenth of seconds) is the value after which the previous content is-  restored i.e. if there was already something from a previous pipe it will be-  put on display again, overwriting the current status.-- A pipe with Timout of 0 will be displayed permanently, just like `PipeReader`-- The boolean option indicates whether new data for this pipe should make xmobar-  appear (unhide, reveal). In this case, the Timeout additionally specifies when-  the window should be hidden again. The output is restored in any case.-- Use it for OSD like status bars e.g. for setting the volume or brightness:+- Timeout (in tenth of seconds) is the value after which the previous+  content is restored i.e. if there was already something from a+  previous pipe it will be put on display again, overwriting the+  current status.+- A pipe with Timout of 0 will be displayed permanently, just like+  `PipeReader`+- The boolean option indicates whether new data for this pipe should+  make xmobar appear (unhide, reveal). In this case, the Timeout+  additionally specifies when the window should be hidden again. The+  output is restored in any case.+- Use it for OSD like status bars e.g. for setting the volume or+  brightness:          Run BufferedPipeReader "bpr"             [ (  0, False, "/tmp/xmobar_window"  )             , ( 15,  True, "/tmp/xmobar_status"  )             ] -  Have your window manager send window titles to `"/tmp/xmobar_window"`. They will-  always be shown and not reveal your xmobar.-  Sending some status information to `"/tmp/xmobar_status"` will reveal xmonad-  for 1.5 seconds and temporarily overwrite the window titles.+  Have your window manager send window titles to+  `"/tmp/xmobar_window"`. They will always be shown and not reveal+  your xmobar.  Sending some status information to+  `"/tmp/xmobar_status"` will reveal xmonad for 1.5 seconds and+  temporarily overwrite the window titles. - Take a look at [samples/status.sh]  [samples/status.sh]: http://github.com/jaor/xmobar/raw/master/samples/status.sh  -`XMonadLog`+<font size="+1">**`XMonadLog`**</font>  - Aliases to XMonadLog - Displays information from xmonad's `_XMONAD_LOG`. You can set this@@ -1302,20 +1339,20 @@ ===================  Andrea Rossato originally designed and implemented xmobar up to-version 0.11.1. Since then, it is maintained and developed by [Jose-Antonio Ortega Ruiz](http://hacks-galore.org/jao/), with the help of-the greater Haskell community.+version 0.11.1. Since then, it is maintained and developed by [jao],+with the help of the greater xmobar and Haskell communities.  In particular, xmobar [incorporates patches] by Ben Boeckel, Roman Cheplyaka, Patrick Chilton, John Goerzen, Reto Hablützel, Juraj Hercek, Tomas Janousek, Spencer Janssen, Jochen Keil, Lennart Kolmodin, Krzysztof Kosciuszkiewicz, Dmitry Kurochkin, Todd Lunter,-Dmitry Malikov, Edward O'Callaghan, Svein Ove, Martin Perner, Jens-Petersen, Alexander Polakov, Petr Rockai, Peter Simons, Andrew-Sackville-West, Alexander Solovyov, John Soros, Artem Tarasov, Sergei-Trofimovich, Thomas Tuegel, Jan Vornberger, Daniel Wagner and Norbert-Zeh.+Dmitry Malikov, David McLean, Thiago Negri, Edward O'Callaghan, Svein+Ove, Martin Perner, Jens Petersen, Alexander Polakov, Petr Rockai,+Peter Simons, Andrew Sackville-West, Alexander Solovyov, John Soros,+Artem Tarasov, Sergei Trofimovich, Thomas Tuegel, Jan Vornberger,+Daniel Wagner and Norbert Zeh. +[jao]: http://jao.io [incorporates patches]: http://www.ohloh.net/p/xmobar/contributors  ## Thanks@@ -1357,9 +1394,9 @@ This software is released under a BSD-style license. See [LICENSE] for more details. -Copyright &copy; 2007-2010 Andrea Rossato+Copyright &copy; 2010-2013 Jose Antonio Ortega Ruiz -Copyright &copy; 2010-2012 Jose Antonio Ortega Ruiz+Copyright &copy; 2007-2010 Andrea Rossato  [Github]: http://github.com/jaor/xmobar/ [Github page]: http://github.com/jaor/xmobar@@ -1371,6 +1408,7 @@ [i3status]: http://i3wm.org/i3status/ [i3status manual]: http://i3wm.org/i3status/manpage.html#_using_i3status_with_xmobar [iwlib]: http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html+[libasound]: http://packages.debian.org/stable/libasound2-dev [hinotify]: http://hackage.haskell.org/package/hinotify/ [libmpd]: http://hackage.haskell.org/package/libmpd/ [dbus]: http://hackage.haskell.org/package/dbus
samples/xmobar.config view
@@ -6,6 +6,7 @@        , position = Top        , lowerOnStart = True        , persistent = False+       , hideOnStart = False        , commands = [ Run Weather "EGPF" ["-t","<station>: <tempC>C","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 36000                     , Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10                     , Run Network "eth1" ["-L","0","-H","32","--normal","green","--high","red"] 10
src/Actions.hs view
@@ -24,4 +24,4 @@  stripActions :: String -> String stripActions s = subRegex actionRegex s "[action=\1]\2[action]"-  where actionRegex = mkRegex "<action=([^>])*>(.+?)</action>"+  where actionRegex = mkRegex "<action=([^>])*>(.+)</action>"
src/Commands.hs view
@@ -62,7 +62,7 @@     start (Com prog args _ r) cb = if r > 0 then go else exec         where go = exec >> tenthSeconds r >> go               exec = do-                (i,o,e,p) <- runInteractiveCommand (unwords (prog:args))+                (i,o,e,p) <- runInteractiveProcess prog args Nothing Nothing                 exit <- waitForProcess p                 let closeHandles = hClose o >> hClose i >> hClose e                     getL = handle (\(SomeException _) -> return "")
src/Localize.hsc view
@@ -46,7 +46,7 @@   itemStr <- nl_langinfo item #ifdef UTF8   str <- peekCString itemStr-  return $ decodeString str+  return $ if (isUTF8Encoded str) then decodeString str else str #else   peekCString itemStr #endif
src/Main.hs view
@@ -32,8 +32,10 @@ import Data.Version (showVersion) import Graphics.X11.Xlib import System.Console.GetOpt+import System.Directory (getHomeDirectory) import System.Exit import System.Environment+import System.FilePath ((</>)) import System.Posix.Files import Control.Monad (unless) @@ -88,13 +90,29 @@                     ": configuration file contains errors at:\n" ++ show err)          return $ parseConfig s +xdgConfigDir :: IO String+xdgConfigDir = do env <- getEnvironment+                  case lookup "XDG_CONFIG_HOME" env of+                       Just val -> return val+                       Nothing  -> getHomeDirectory >>= return . (</> ".config")++xmobarConfigDir :: IO FilePath+xmobarConfigDir = xdgConfigDir >>= return . (</> "xmobar")++getXdgConfigFile :: IO FilePath+getXdgConfigFile = xmobarConfigDir >>= return . (</> "xmobarrc")+ -- | Read default configuration file or load the default config readDefaultConfig :: IO (Config,[String]) readDefaultConfig = do+  xdgconf <- getXdgConfigFile+  x <- io $ fileExist xdgconf   home <- io $ getEnv "HOME"   let path = home ++ "/.xmobarrc"   f <- io $ fileExist path-  if f then readConfig path else return (defaultConfig,[])+  if x then readConfig path+       else if f then readConfig path+                 else return (defaultConfig,[])  data Opts = Help           | Version
src/Plugins/Monitors.hs view
@@ -3,7 +3,7 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Xmobar.Plugins.Monitors--- Copyright   :  (c) 2010, 2011, 2012 Jose Antonio Ortega Ruiz+-- Copyright   :  (c) 2010, 2011, 2012, 2013 Jose Antonio Ortega Ruiz --                (c) 2007-10 Andrea Rossato -- License     :  BSD-style (see LICENSE) --@@ -52,7 +52,9 @@ data Monitors = Weather      Station     Args Rate               | Network      Interface   Args Rate               | DynNetwork               Args Rate-              | BatteryP     [String]    Args Rate+              | BatteryP     Args        Args Rate+              | BatteryN     Args        Args Rate Alias+              | Battery      Args        Rate               | DiskU        DiskSpec    Args Rate               | DiskIO       DiskSpec    Args Rate               | Thermal      Zone        Args Rate@@ -61,7 +63,6 @@               | Swap         Args        Rate               | Cpu          Args        Rate               | MultiCpu     Args        Rate-              | Battery      Args        Rate               | Brightness   Args        Rate               | CpuFreq      Args        Rate               | CoreTemp     Args        Rate@@ -106,6 +107,7 @@     alias (MultiCpu _ _) = "multicpu"     alias (Battery _ _) = "battery"     alias (BatteryP _ _ _)= "battery"+    alias (BatteryN _ _ _ a)= a     alias (Brightness _ _) = "bright"     alias (CpuFreq _ _) = "cpufreq"     alias (TopProc _ _) = "top"@@ -142,6 +144,7 @@     start (Swap a r) = runM a swapConfig runSwap r     start (Battery a r) = runM a battConfig runBatt r     start (BatteryP s a r) = runM a battConfig (runBatt' s) r+    start (BatteryN s a r _) = runM a battConfig (runBatt' s) r     start (Brightness a r) = runM a brightConfig runBright r     start (CpuFreq a r) = runM a cpuFreqConfig runCpuFreq r     start (CoreTemp a r) = runM a coreTempConfig runCoreTemp r
src/Plugins/Monitors/Batt.hs view
@@ -163,16 +163,18 @@   case c of     Result x w t s ->       do l <- fmtPercent x-         let ts = [fmtTime $ floor t, fmtWatts w opts suffix d]-         parseTemplate (l ++ s:ts)-    NA -> return "N/A"+         ws <- fmtWatts w opts suffix d+         parseTemplate (l ++ [s, fmtTime $ floor t, ws])+    NA -> getConfigValue naString   where fmtPercent :: Float -> Monitor [String]         fmtPercent x = do           let x' = minimum [1, x]           p <- showPercentWithColors x'           b <- showPercentBar (100 * x') x'           return [b, p]-        fmtWatts x o s d = color x o $ showDigits d x ++ (if s then "W" else "")+        fmtWatts x o s d = do+          ws <- showWithPadding $ showDigits d x ++ (if s then "W" else "")+          return $ color x o ws         fmtTime :: Integer -> String         fmtTime x = hours ++ ":" ++ if length minutes == 2                                     then minutes else '0' : minutes
src/Plugins/Monitors/Common.hs view
@@ -89,6 +89,7 @@        , barFore     :: IORef String        , barWidth    :: IORef Int        , useSuffix   :: IORef Bool+       , naString    :: IORef String        }  -- | from 'http:\/\/www.haskell.org\/hawiki\/MonadState'@@ -132,7 +133,8 @@        bf <- newIORef "#"        bw <- newIORef 10        up <- newIORef False-       return $ MC nc l lc h hc t e p d mn mx pc pr bb bf bw up+       na <- newIORef "N/A"+       return $ MC nc l lc h hc t e p d mn mx pc pr bb bf bw up na  data Opts = HighColor String           | NormalColor String@@ -151,27 +153,29 @@           | BarFore String           | BarWidth String           | UseSuffix String+          | NAString String  options :: [OptDescr Opts] options =     [-      Option "H"  ["High"] (ReqArg High "number") "The high threshold"-    , Option "L"  ["Low"] (ReqArg Low "number") "The low threshold"-    , Option "h"  ["high"] (ReqArg HighColor "color number") "Color for the high threshold: ex \"#FF0000\""-    , Option "n"  ["normal"] (ReqArg NormalColor "color number") "Color for the normal threshold: ex \"#00FF00\""-    , Option "l"  ["low"] (ReqArg LowColor "color number") "Color for the low threshold: ex \"#0000FF\""-    , Option "t"  ["template"] (ReqArg Template "output template") "Output template."-    , Option "S"  ["suffix"] (ReqArg UseSuffix "True/False") "Use % to display percents or other suffixes."-    , Option "d"  ["ddigits"] (ReqArg DecDigits "decimal digits") "Number of decimal digits to display."-    , Option "p"  ["ppad"] (ReqArg PercentPad "percent padding") "Minimum percentage width."-    , Option "m"  ["minwidth"] (ReqArg MinWidth "minimum width") "Minimum field width"-    , Option "M"  ["maxwidth"] (ReqArg MaxWidth "maximum width") "Maximum field width"-    , Option "w"  ["width"] (ReqArg Width "fixed width") "Fixed field width"-    , Option "c"  ["padchars"] (ReqArg PadChars "padding chars") "Characters to use for padding"-    , Option "a"  ["align"] (ReqArg PadAlign "padding alignment") "'l' for left padding, 'r' for right"-    , Option "b"  ["bback"] (ReqArg BarBack "bar background") "Characters used to draw bar backgrounds"-    , Option "f"  ["bfore"] (ReqArg BarFore "bar foreground") "Characters used to draw bar foregrounds"-    , Option "W"  ["bwidth"] (ReqArg BarWidth "bar width") "Bar width"+      Option "H" ["High"] (ReqArg High "number") "The high threshold"+    , Option "L" ["Low"] (ReqArg Low "number") "The low threshold"+    , Option "h" ["high"] (ReqArg HighColor "color number") "Color for the high threshold: ex \"#FF0000\""+    , Option "n" ["normal"] (ReqArg NormalColor "color number") "Color for the normal threshold: ex \"#00FF00\""+    , Option "l" ["low"] (ReqArg LowColor "color number") "Color for the low threshold: ex \"#0000FF\""+    , Option "t" ["template"] (ReqArg Template "output template") "Output template."+    , Option "S" ["suffix"] (ReqArg UseSuffix "True/False") "Use % to display percents or other suffixes."+    , Option "d" ["ddigits"] (ReqArg DecDigits "decimal digits") "Number of decimal digits to display."+    , Option "p" ["ppad"] (ReqArg PercentPad "percent padding") "Minimum percentage width."+    , Option "m" ["minwidth"] (ReqArg MinWidth "minimum width") "Minimum field width"+    , Option "M" ["maxwidth"] (ReqArg MaxWidth "maximum width") "Maximum field width"+    , Option "w" ["width"] (ReqArg Width "fixed width") "Fixed field width"+    , Option "c" ["padchars"] (ReqArg PadChars "padding chars") "Characters to use for padding"+    , Option "a" ["align"] (ReqArg PadAlign "padding alignment") "'l' for left padding, 'r' for right"+    , Option "b" ["bback"] (ReqArg BarBack "bar background") "Characters used to draw bar backgrounds"+    , Option "f" ["bfore"] (ReqArg BarFore "bar foreground") "Characters used to draw bar foregrounds"+    , Option "W" ["bwidth"] (ReqArg BarWidth "bar width") "Bar width"+    , Option "x" ["nastring"] (ReqArg NAString "N/A string") "String used when the monitor is not available"     ]  doArgs :: [String] -> ([String] -> Monitor String) -> Monitor String@@ -205,7 +209,8 @@           BarBack     s -> setConfigValue s barBack           BarFore     s -> setConfigValue s barFore           BarWidth    w -> setConfigValue (nz w) barWidth-          UseSuffix   u -> setConfigValue (bool u) useSuffix) >> next+          UseSuffix   u -> setConfigValue (bool u) useSuffix+          NAString    s -> setConfigValue s naString) >> next  runM :: [String] -> IO MConfig -> ([String] -> Monitor String) -> Int         -> (String -> IO ()) -> IO ()
src/Plugins/Monitors/CoreTemp.hs view
@@ -34,10 +34,11 @@ -- Function retrieves monitor string holding the core temperature -- (or temperatures) runCoreTemp :: [String] -> Monitor String-runCoreTemp _ = let path = ["/sys/bus/platform/devices/coretemp.",-                            "/temp",-                            "_input"]-                    lbl  = Just ("_label", read . (dropWhile (not . isDigit)))-                    divisor = 1e3 :: Double-                    failureMessage = "CoreTemp: N/A"-                in  checkedDataRetrieval failureMessage path lbl (/divisor) show+runCoreTemp _ = do+   dn <- getConfigValue decDigits+   failureMessage <- getConfigValue naString+   let path = ["/sys/bus/platform/devices/coretemp.", "/temp", "_input"]+       lbl  = Just ("_label", read . (dropWhile (not . isDigit)))+       divisor = 1e3 :: Double+       show' = showDigits (max 0 dn)+   checkedDataRetrieval failureMessage path lbl (/divisor) show'
src/Plugins/Monitors/CpuFreq.hs view
@@ -30,10 +30,10 @@ -- | -- Function retrieves monitor string holding the cpu frequency (or frequencies) runCpuFreq :: [String] -> Monitor String-runCpuFreq _ = let path = ["/sys/devices/system/cpu/cpu", "/cpufreq/scaling_cur_freq"]-                   divisor = 1e6 :: Double-                   failureMessage = "CpuFreq: N/A"-                   fmt x | x < 1     = (show (round (x * 1000) :: Integer)) ++ "MHz"-                         | otherwise = (show x) ++ "GHz"-               in  checkedDataRetrieval failureMessage path Nothing (/divisor) fmt-+runCpuFreq _ = do+  let path = ["/sys/devices/system/cpu/cpu", "/cpufreq/scaling_cur_freq"]+      divisor = 1e6 :: Double+      fmt x | x < 1 = (show (round (x * 1000) :: Integer)) ++ "MHz"+            | otherwise = (show x) ++ "GHz"+  failureMessage <- getConfigValue naString+  checkedDataRetrieval failureMessage path Nothing (/divisor) fmt
src/Plugins/Monitors/Mem.hs view
@@ -52,7 +52,7 @@        fs <- showPercentWithColors fr        s <- mapM (showWithColors f) xs        return (ub:fb:rs:fs:s)-formatMem _ = return $ replicate 10 "N/A"+formatMem _ = replicate 10 `fmap` getConfigValue naString  runMem :: [String] -> Monitor String runMem _ =
src/Plugins/Monitors/Net.hs view
@@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Plugins.Monitors.Net--- Copyright   :  (c) 2011, 2012 Jose Antonio Ortega Ruiz+-- Copyright   :  (c) 2011, 2012, 2013 Jose Antonio Ortega Ruiz --                (c) 2007-2010 Andrea Rossato -- License     :  BSD-style (see LICENSE) --@@ -114,7 +114,7 @@         (tx, tb) <- formatNet t         parseTemplate [d,rx,tx,rb,tb]     NI _ -> return ""-    NA -> return "N/A"+    NA -> getConfigValue naString  parseNet :: NetDevRef -> String -> IO NetDev parseNet nref nd = do
src/Plugins/Monitors/ThermalZone.hs view
@@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- | -- Module       :  Plugins.Monitors.ThermalZone--- Copyright    :  (c) 2011 Jose Antonio Ortega Ruiz+-- Copyright    :  (c) 2011, 2013 Jose Antonio Ortega Ruiz -- License      :  BSD3-style (see LICENSE) -- -- Maintainer   :  jao@gnu.org@@ -39,5 +39,4 @@       then do mdegrees <- io $ B.readFile file >>= parse               temp <- showWithColors show (mdegrees `quot` 1000)               parseTemplate [ temp ]-      else return "N/A"-+      else getConfigValue naString
src/Plugins/Monitors/Volume.hs view
@@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module      :  Plugins.Monitors.Volume--- Copyright   :  (c) 2011 Thomas Tuegel+-- Copyright   :  (c) 2011, 2013 Thomas Tuegel -- License     :  BSD-style (see LICENSE) -- -- Maintainer  :  Jose A. Ortega Ruiz <jao@gnu.org>@@ -135,7 +135,7 @@     liftMaybe = fmap (liftM2 (,) (fmap fst) (fmap snd)) . sequenceA      liftMonitor :: Maybe (Monitor String) -> Monitor String-    liftMonitor Nothing = return unavailable+    liftMonitor Nothing = unavailable     liftMonitor (Just m) = m      getDB :: Maybe Volume -> Monitor (Maybe Integer)@@ -152,11 +152,11 @@     getSw (Just s) = io $ getChannel FrontLeft s      getFormatDB :: VolumeOpts -> Maybe Integer -> Monitor String-    getFormatDB _ Nothing = return unavailable+    getFormatDB _ Nothing = unavailable     getFormatDB opts (Just d) = formatDb opts d      getFormatSwitch :: VolumeOpts -> Maybe Bool -> Monitor String-    getFormatSwitch _ Nothing = return unavailable+    getFormatSwitch _ Nothing = unavailable     getFormatSwitch opts (Just sw) = formatSwitch opts sw -    unavailable = "N/A"+    unavailable = getConfigValue naString
src/Plugins/Monitors/Weather.hs view
@@ -89,11 +89,28 @@                skipRestOfLine                return $ read s +{-+    example of 'http://weather.noaa.gov/pub/data/observations/metar/decoded/VTUD.TXT':+        Station name not available+        Aug 11, 2013 - 10:00 AM EDT / 2013.08.11 1400 UTC+        Wind: from the N (350 degrees) at 1 MPH (1 KT):0+        Visibility: 4 mile(s):0+        Sky conditions: mostly clear+        Temperature: 77 F (25 C)+        Dew Point: 73 F (23 C)+        Relative Humidity: 88%+        Pressure (altimeter): 29.77 in. Hg (1008 hPa)+        ob: VTUD 111400Z 35001KT 8000 FEW030 25/23 Q1008 A2977 INFO R RWY30+        cycle: 14+-} parseData :: Parser [WeatherInfo] parseData =-    do st <- getAllBut ","-       space-       ss <- getAllBut "("+    do (st, ss) <- try (string "Station name not available" >> return ("??", "??")) <|>+                   (do st <- getAllBut ","+                       space+                       ss <- getAllBut "("+                       return (st, ss)+                   )        skipRestOfLine >> getAllBut "/"        (y,m,d,h) <- pTime        w <- getAfterString "Wind: "@@ -132,7 +149,7 @@     do cel <- showWithColors show tC        far <- showWithColors show tF        parseTemplate [st, ss, y, m, d, h, w, v, sk, cel, far, dp, show r , show p ]-formatWeather _ = return "N/A"+formatWeather _ = getConfigValue naString  runWeather :: [String] -> Monitor String runWeather str =
src/Plugins/Monitors/Wireless.hs view
@@ -24,11 +24,14 @@ runWireless :: [String] -> Monitor String runWireless (iface:_) = do   wi <- io $ getWirelessInfo iface+  na <- getConfigValue naString   let essid = wiEssid wi       qlty = fromIntegral $ wiQuality wi-      e = if essid == "" then "N/A" else essid+      e = if essid == "" then na else essid   ep <- showWithPadding e-  q <- if qlty >= 0 then showPercentWithColors (qlty/100) else showWithPadding ""+  q <- if qlty >= 0+       then showPercentWithColors (qlty / 100)+       else showWithPadding ""   qb <- showPercentBar qlty (qlty / 100)   parseTemplate [ep, q, qb]-runWireless _ = return ""+runWireless _ = getConfigValue naString
src/Plugins/StdinReader.hs view
@@ -8,11 +8,15 @@ -- Stability   :  unstable -- Portability :  unportable ----- A plugin for reading from stdin+-- A plugin for reading from `stdin`. --+-- Exports:+-- - `StdinReader` to safely display stdin content (striping actions).+-- - `UnsafeStdinReader` to display stdin content as-is.+-- ----------------------------------------------------------------------------- -module Plugins.StdinReader where+module Plugins.StdinReader (StdinReader(..)) where  import Prelude import System.Posix.Process@@ -22,14 +26,19 @@ import Plugins import Actions (stripActions) -data StdinReader = StdinReader deriving (Read, Show)+data StdinReader = StdinReader | UnsafeStdinReader+  deriving (Read, Show)  instance Exec StdinReader where-  start StdinReader cb = do+  start stdinReader cb = do     s <- handle (\(SomeException e) -> do hPrint stderr e; return "")                 (hGetLineSafe stdin)-    cb (stripActions s)+    cb $ escape stdinReader s     eof <- hIsEOF stdin     if eof       then exitImmediately ExitSuccess-      else start StdinReader cb+      else start stdinReader cb++escape :: StdinReader -> String -> String+escape StdinReader = stripActions+escape UnsafeStdinReader = id
xmobar.cabal view
@@ -1,5 +1,5 @@ name:               xmobar-version:            0.18+version:            0.19 homepage:           http://projects.haskell.org/xmobar/ bug-reports:        http://code.google.com/p/xmobar/issues synopsis:           A Minimalistic Text Based Status Bar