summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2013-10-27 15:24:37 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-10-27 15:24:37 +0100
commit69a552a786d05011e3bad23f38add8f99c62468c (patch)
tree5e189b1c34b872481788d1d4a728bab058f08557
parentd7a3df4de84acf1a7a8cd714feb4a2cdd42a127d (diff)
downloadxmobar-69a552a786d05011e3bad23f38add8f99c62468c.tar.gz
xmobar-69a552a786d05011e3bad23f38add8f99c62468c.tar.bz2
Using width options in wattage display (fixes #118)
-rw-r--r--news.md5
-rw-r--r--src/Plugins/Monitors/Batt.hs8
2 files changed, 9 insertions, 4 deletions
diff --git a/news.md b/news.md
index 64c7852..c1d85b5 100644
--- a/news.md
+++ b/news.md
@@ -16,7 +16,9 @@ _New features_
_Bug fixes_
- - Honour the "-d" option in `CoreTemp` ([github #115])
+ - Honour the width options `-w`, `-m` and `-M` in battery monitors
+ watts display ([github #118]).
+ - Honour 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]).
@@ -28,6 +30,7 @@ _Bug fixes_
[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
## Version 0.18 (June 5, 2013)
diff --git a/src/Plugins/Monitors/Batt.hs b/src/Plugins/Monitors/Batt.hs
index 4c0232f..410aec6 100644
--- a/src/Plugins/Monitors/Batt.hs
+++ b/src/Plugins/Monitors/Batt.hs
@@ -163,8 +163,8 @@ runBatt' bfs args = do
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)
+ ws <- fmtWatts w opts suffix d
+ parseTemplate (l ++ [s, fmtTime $ floor t, ws])
NA -> return "N/A"
where fmtPercent :: Float -> Monitor [String]
fmtPercent x = do
@@ -172,7 +172,9 @@ runBatt' bfs args = do
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