summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors/Bright.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2014-09-24 20:54:16 +0200
committerjao <jao@gnu.org>2014-09-24 20:54:16 +0200
commitb0f07db920d9ed446532dfc1aaddd3e7f57d0592 (patch)
tree53c0c3ee80a8db536b6fb6decc492c72e7c5a663 /src/Plugins/Monitors/Bright.hs
parentb7973cb8af3b03f6add1a0f0bb4cc790b1223609 (diff)
parentf8b7b22253d72b7b6ecf83bac87a8cda41040f49 (diff)
downloadxmobar-b0f07db920d9ed446532dfc1aaddd3e7f57d0592.tar.gz
xmobar-b0f07db920d9ed446532dfc1aaddd3e7f57d0592.tar.bz2
Merge branch 'dynamic-strings' of https://github.com/projedi/xmobar
Diffstat (limited to 'src/Plugins/Monitors/Bright.hs')
-rw-r--r--src/Plugins/Monitors/Bright.hs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/Plugins/Monitors/Bright.hs b/src/Plugins/Monitors/Bright.hs
index d29c5a4..cb510f6 100644
--- a/src/Plugins/Monitors/Bright.hs
+++ b/src/Plugins/Monitors/Bright.hs
@@ -26,18 +26,22 @@ import Plugins.Monitors.Common
data BrightOpts = BrightOpts { subDir :: String
, currBright :: String
, maxBright :: String
+ , curBrightIconPattern :: Maybe IconPattern
}
defaultOpts :: BrightOpts
defaultOpts = BrightOpts { subDir = "acpi_video0"
, currBright = "actual_brightness"
, maxBright = "max_brightness"
+ , curBrightIconPattern = Nothing
}
options :: [OptDescr (BrightOpts -> BrightOpts)]
options = [ Option "D" ["device"] (ReqArg (\x o -> o { subDir = x }) "") ""
, Option "C" ["curr"] (ReqArg (\x o -> o { currBright = x }) "") ""
, Option "M" ["max"] (ReqArg (\x o -> o { maxBright = x }) "") ""
+ , Option "" ["brightness-icon-pattern"] (ReqArg (\x o ->
+ o { curBrightIconPattern = Just $ parseIconPattern x }) "") ""
]
-- from Batt.hs
@@ -52,7 +56,7 @@ sysDir = "/sys/class/backlight/"
brightConfig :: IO MConfig
brightConfig = mkMConfig "<percent>" -- template
- ["vbar", "percent", "bar"] -- replacements
+ ["vbar", "percent", "bar", "ipat"] -- replacements
data Files = Files { fCurr :: String
, fMax :: String
@@ -76,12 +80,13 @@ runBright args = do
c <- io $ readBright f
case f of
NoFiles -> return "hurz"
- _ -> fmtPercent c >>= parseTemplate
- where fmtPercent :: Float -> Monitor [String]
- fmtPercent c = do r <- showVerticalBar (100 * c) c
- s <- showPercentWithColors c
- t <- showPercentBar (100 * c) c
- return [r,s,t]
+ _ -> fmtPercent opts c >>= parseTemplate
+ where fmtPercent :: BrightOpts -> Float -> Monitor [String]
+ fmtPercent opts c = do r <- showVerticalBar (100 * c) c
+ s <- showPercentWithColors c
+ t <- showPercentBar (100 * c) c
+ d <- showIconPattern (curBrightIconPattern opts) c
+ return [r,s,t,d]
readBright :: Files -> IO Float
readBright NoFiles = return 0