From 7457cf578a283264e0c1297eb5a672601aca9a38 Mon Sep 17 00:00:00 2001 From: Eric Mrak Date: Thu, 13 Mar 2014 20:06:09 -0700 Subject: Brightness hbar is now vbar --- readme.md | 2 +- src/Plugins/Monitors/Bright.hs | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/readme.md b/readme.md index 5776aff..ceb3e9d 100644 --- a/readme.md +++ b/readme.md @@ -1071,7 +1071,7 @@ more than one battery. - `-M`: file with the maximum brightness (default: max_brightness) - Variables that can be used with the `-t`/`--template` argument: - `hbar`, `percent`, `bar` + `vbar`, `percent`, `bar` - Default template: `` - Example: diff --git a/src/Plugins/Monitors/Bright.hs b/src/Plugins/Monitors/Bright.hs index 0679ab8..023478a 100644 --- a/src/Plugins/Monitors/Bright.hs +++ b/src/Plugins/Monitors/Bright.hs @@ -16,7 +16,6 @@ module Plugins.Monitors.Bright (brightConfig, runBright) where import Control.Exception (SomeException, handle) import qualified Data.ByteString.Lazy.Char8 as B -import Data.Char import System.FilePath (()) import System.Posix.Files (fileExist) import System.Console.GetOpt @@ -52,7 +51,7 @@ sysDir = "/sys/class/backlight/" brightConfig :: IO MConfig brightConfig = mkMConfig "" -- template - ["hbar", "percent", "bar"] -- replacements + ["vbar", "percent", "bar"] -- replacements data Files = Files { fCurr :: String , fMax :: String @@ -78,7 +77,7 @@ runBright args = do NoFiles -> return "hurz" _ -> fmtPercent c >>= parseTemplate where fmtPercent :: Float -> Monitor [String] - fmtPercent c = do r <- showHorizontalBar (100 * c) + fmtPercent c = do r <- showVerticalBar (100 * c) s <- showPercentWithColors c t <- showPercentBar (100 * c) c return [r,s,t] @@ -92,14 +91,3 @@ readBright files = do where grab f = handle handler (fmap (read . B.unpack) $ B.readFile f) handler = const (return 0) :: SomeException -> IO Float -showHorizontalBar :: Float -> Monitor String -showHorizontalBar x = do - return $ [convert x] - where convert :: Float -> Char - convert val - | t <= 9600 = ' ' - | t > 9608 = chr 9608 - | otherwise = chr t - where - -- we scale from 0 to 100, we have 8 slots (9 elements), 100/8 = 12 - t = 9600 + ((round val) `div` 12) -- cgit v1.2.3