summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--readme.md1
-rw-r--r--src/Xmobar/Plugins/Monitors/Batt.hs13
-rw-r--r--src/Xmobar/Plugins/Monitors/Common/Output.hs3
4 files changed, 13 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md
index fb027c5..c0957ad 100644
--- a/changelog.md
+++ b/changelog.md
@@ -5,6 +5,7 @@ _New features_
- New plugin `MailX` extending `Mail` with colors and prefix/suffix.
- New options `--lows`, `--mediums`, and `--highs` for `Battery`
to display an additional string depending on battery level.
+ - New option `-P` in `Battery` to add a `%` symbol to `<left>`.
- New options `-L` and `-H` for `Volume` to set low and high volume
levels, as well as `-l`, `-m`, and `-h` to display an additional
string depending on current volume level.
diff --git a/readme.md b/readme.md
index 6cff2ab..073a181 100644
--- a/readme.md
+++ b/readme.md
@@ -911,6 +911,7 @@ specification, such as `("clear", "<icon=weather-clear.xbm/>")`.
percentage left in the battery is less or equal than the threshold
given by the `-A` option. If not present, no action is
undertaken.
+ - `-P`: to include a percentage symbol in `left`.
- `--on-icon-pattern`: dynamic string for current battery charge
when AC is "on" in `leftipat`.
- `--off-icon-pattern`: dynamic string for current battery charge
diff --git a/src/Xmobar/Plugins/Monitors/Batt.hs b/src/Xmobar/Plugins/Monitors/Batt.hs
index 16137b1..3f407b6 100644
--- a/src/Xmobar/Plugins/Monitors/Batt.hs
+++ b/src/Xmobar/Plugins/Monitors/Batt.hs
@@ -48,6 +48,7 @@ data BattOpts = BattOpts
, lowString :: String
, mediumString :: String
, highString :: String
+ , incPerc :: Bool
}
defaultOpts :: BattOpts
@@ -71,6 +72,7 @@ defaultOpts = BattOpts
, lowString = ""
, mediumString = ""
, highString = ""
+ , incPerc = False
}
options :: [OptDescr (BattOpts -> BattOpts)]
@@ -87,6 +89,7 @@ options =
, Option "f" ["online"] (ReqArg (\x o -> o { onlineFile = x }) "") ""
, Option "s" ["scale"] (ReqArg (\x o -> o {scale = read x}) "") ""
, Option "a" ["action"] (ReqArg (\x o -> o { onLowAction = Just x }) "") ""
+ , Option "P" ["percent"] (NoArg (\o -> o {incPerc = True})) ""
, Option "A" ["action-threshold"]
(ReqArg (\x o -> o { actionThreshold = read x }) "") ""
, Option "" ["on-icon-pattern"] (ReqArg (\x o ->
@@ -243,13 +246,14 @@ runBatt = runBatt' ["BAT", "BAT0", "BAT1", "BAT2"]
runBatt' :: [String] -> [String] -> Monitor String
runBatt' bfs args = do
opts <- io $ parseOpts args
+ let sp = incPerc opts
c <- io $ readBatteries opts =<< mapM batteryFiles bfs
suffix <- getConfigValue useSuffix
d <- getConfigValue decDigits
nas <- getConfigValue naString
case c of
Result x w t s ->
- do l <- fmtPercent x
+ do l <- fmtPercent x sp
ws <- fmtWatts w opts suffix d
si <- getIconPattern opts s x
st <- showWithColors'
@@ -257,13 +261,14 @@ runBatt' bfs args = do
(100 * x)
parseTemplate (l ++ [st, fmtTime $ floor t, ws, si])
NA -> getConfigValue naString
- where fmtPercent :: Float -> Monitor [String]
- fmtPercent x = do
+ where fmtPercent :: Float -> Bool -> Monitor [String]
+ fmtPercent x sp = do
let x' = minimum [1, x]
+ pc <- if sp then colorizeString (100 * x') "%" else return ""
p <- showPercentWithColors x'
b <- showPercentBar (100 * x') x'
vb <- showVerticalBar (100 * x') x'
- return [b, vb, p]
+ return [b, vb, p ++ pc]
fmtWatts x o s d = do
ws <- showWithPadding $ showDigits d x ++ (if s then "W" else "")
return $ color x o ws
diff --git a/src/Xmobar/Plugins/Monitors/Common/Output.hs b/src/Xmobar/Plugins/Monitors/Common/Output.hs
index 53c5b0f..7a14a74 100644
--- a/src/Xmobar/Plugins/Monitors/Common/Output.hs
+++ b/src/Xmobar/Plugins/Monitors/Common/Output.hs
@@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- |
-- Module: Xmobar.Plugins.Monitors.Strings
--- Copyright: (c) 2018 Jose Antonio Ortega Ruiz
+-- Copyright: (c) 2018, 2019 Jose Antonio Ortega Ruiz
-- License: BSD3-style (see LICENSE)
--
-- Maintainer: jao@gnu.org
@@ -18,6 +18,7 @@
module Xmobar.Plugins.Monitors.Common.Output ( IconPattern
, parseIconPattern
, padString
+ , colorizeString
, showWithPadding
, showWithColors
, showWithColors'