packages feed

xmobar 0.24.2 → 0.24.3

raw patch · 4 files changed

+22/−6 lines, 4 files

Files

news.md view
@@ -1,5 +1,14 @@ % xmobar - Release notes +## Version 0.24.3 (Sep 5, 2016)++_Bug fixes_++  - Battery monitor: fixes for cases where status is not consistently+    reported by the kernel (see [issue #271]).++[issue #271]: https://github.com/jaor/xmobar/issues/271+ ## Version 0.24.2 (Aug 8, 2016)  _Bug fixes_
readme.md view
@@ -10,7 +10,7 @@ features, like dynamic color management, icons, output templates, and extensibility through plugins. -This page documents xmobar 0.24.2 (see [release notes]).+This page documents xmobar 0.24.3 (see [release notes]).  [This screenshot] shows xmobar running under [sawfish], with antialiased fonts. And [this one] is my desktop with [xmonad] and two
src/Plugins/Monitors/Batt.hs view
@@ -147,7 +147,7 @@   where onError = const (return False) :: SomeException -> IO Bool  readBattery :: Float -> Files -> IO Battery-readBattery _ NoFiles = return $ Battery 0 0 0 "Idle"+readBattery _ NoFiles = return $ Battery 0 0 0 "Unknown" readBattery sc files =     do a <- grab $ fFull files        b <- grab $ fNow files@@ -162,13 +162,16 @@     where grab f = handle onError $ withFile f ReadMode (fmap read . hGetLine)           onError = const (return (-1)) :: SomeException -> IO Float           grabs f = handle onError' $ withFile f ReadMode hGetLine-          onError' = const (return "Idle") :: SomeException -> IO String+          onError' = const (return "Unknown") :: SomeException -> IO String  -- sortOn is only available starting at ghc 7.10 sortOn :: Ord b => (a -> b) -> [a] -> [a] sortOn f =   map snd . sortBy (comparing fst) . map (\x -> let y = f x in y `seq` (y, x)) +mostCommonDef :: Eq a => a -> [a] -> a+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)@@ -183,8 +186,12 @@            statuses :: [Status]            statuses = map (fromMaybe Unknown . readMaybe)                           (sort (map status bats))-           acst = head $ last $ sortOn length (group statuses)-       return $ if isNaN left then NA else Result left watts time acst+           acst = mostCommonDef Unknown $ filter (Unknown/=) statuses+           racst | acst /= Unknown = acst+                 | time == 0 = Idle+                 | ac = Charging+                 | otherwise = Discharging+       return $ if isNaN left then NA else Result left watts time racst  runBatt :: [String] -> Monitor String runBatt = runBatt' ["BAT0","BAT1","BAT2"]
xmobar.cabal view
@@ -1,5 +1,5 @@ name:               xmobar-version:            0.24.2+version:            0.24.3 homepage:           http://xmobar.org synopsis:           A Minimalistic Text Based Status Bar description: 	    Xmobar is a minimalistic text based status bar.