diff options
author | jao <jao@gnu.org> | 2018-02-18 22:38:51 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2018-02-18 22:38:51 +0100 |
commit | e154d88e03e05b2dad34408b05ed944024036ba5 (patch) | |
tree | a49a3f706413af4f93a077254b762901ba50d998 | |
parent | 3aed229c30d1562f0e29748a78362cdd3722ae20 (diff) | |
download | xmobar-e154d88e03e05b2dad34408b05ed944024036ba5.tar.gz xmobar-e154d88e03e05b2dad34408b05ed944024036ba5.tar.bz2 |
Batt: Try also "BAT" (fixes #338)
-rw-r--r-- | readme.md | 6 | ||||
-rw-r--r-- | src/Plugins/Monitors/Batt.hs | 9 |
2 files changed, 9 insertions, 6 deletions
@@ -816,15 +816,17 @@ something like: ### `Battery Args RefreshRate` -- Same as `BatteryP ["BAT0", "BAT1", "BAT2"] Args RefreshRate`. +- Same as `BatteryP ["BAT", "BAT0", "BAT1", "BAT2"] Args RefreshRate`. ### `BatteryP Dirs Args RefreshRate` - Aliases to `battery` + - Dirs: list of directories in `/sys/class/power_supply/` where to look for the ACPI files of each battery. Example: - `["BAT0","BAT1","BAT2"]`. Only the first 3 directories will be + `["BAT0","BAT1","BAT2"]`. Only up to 3 existing directories will be searched. + - Args: default monitor arguments, plus the following specific ones (these options, being specific to the monitor, are to be specified after a `--` in the argument list): diff --git a/src/Plugins/Monitors/Batt.hs b/src/Plugins/Monitors/Batt.hs index 0469ac2..eeeb049 100644 --- a/src/Plugins/Monitors/Batt.hs +++ b/src/Plugins/Monitors/Batt.hs @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Batt --- Copyright : (c) 2010, 2011, 2012, 2013, 2015, 2016 Jose A Ortega +-- Copyright : (c) 2010, 2011, 2012, 2013, 2015, 2016, 2018 Jose A Ortega -- (c) 2010 Andrea Rossato, Petr Rockai -- License : BSD-style (see LICENSE) -- @@ -107,7 +107,7 @@ data Files = Files , fCurrent :: String , fStatus :: String , isCurrent :: Bool - } | NoFiles + } | NoFiles deriving Eq data Battery = Battery { full :: !Float @@ -174,7 +174,8 @@ mostCommonDef x xs = head $ last $ [x] : sortOn length (group xs) readBatteries :: BattOpts -> [Files] -> IO Result readBatteries opts bfs = - do bats <- mapM (readBattery (scale opts)) (take 3 bfs) + do let bfs' = filter (/= NoFiles) bfs + bats <- mapM (readBattery (scale opts)) (take 3 bfs') ac <- haveAc (onlineFile opts) let sign = if ac then 1 else -1 ft = sum (map full bats) @@ -194,7 +195,7 @@ readBatteries opts bfs = return $ if isNaN left then NA else Result left watts time racst runBatt :: [String] -> Monitor String -runBatt = runBatt' ["BAT0","BAT1","BAT2"] +runBatt = runBatt' ["BAT", "BAT0", "BAT1", "BAT2"] runBatt' :: [String] -> [String] -> Monitor String runBatt' bfs args = do |