Hello community, here is the log from the commit of package xmobar for openSUSE:Factory checked in at 2019-08-24 18:44:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/xmobar (Old) and /work/SRC/openSUSE:Factory/.xmobar.new.7948 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "xmobar" Sat Aug 24 18:44:35 2019 rev:10 rq:725526 version:0.30 Changes: -------- --- /work/SRC/openSUSE:Factory/xmobar/xmobar.changes 2019-06-12 13:18:08.740583265 +0200 +++ /work/SRC/openSUSE:Factory/.xmobar.new.7948/xmobar.changes 2019-08-24 18:44:39.173767452 +0200 @@ -1,0 +2,19 @@ +Fri Aug 23 02:01:35 UTC 2019 - [email protected] + +- Update xmobar to version 0.30. + ## Version 0.30 (August, 2019) + + _New features_ + + - New monitor `MultiCoreTemp`, thanks to Felix Springer. + - `DiskIO`: Additional template variables for absolute number of + bytes rather than speeds (see [issue #390]. + - `WeatherX`: An extension to the `Weather` monitor allowing the + spefication of custom strings or icons for sky conditions. + - The battery monitors accept the new arguments `-a` and `-A` to + specify a system command executed if battery left goes beyond a + given threshold. + + [issue #390]: https://github.com/jaor/xmobar/issues/390 + +------------------------------------------------------------------- Old: ---- xmobar-0.29.5.tar.gz New: ---- xmobar-0.30.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ xmobar.spec ++++++ --- /var/tmp/diff_new_pack.kpluLM/_old 2019-08-24 18:44:40.057767367 +0200 +++ /var/tmp/diff_new_pack.kpluLM/_new 2019-08-24 18:44:40.061767366 +0200 @@ -19,7 +19,7 @@ %global pkg_name xmobar %bcond_with tests Name: %{pkg_name} -Version: 0.29.5 +Version: 0.30 Release: 0 Summary: A Minimalistic Text Based Status Bar License: BSD-3-Clause ++++++ xmobar-0.29.5.tar.gz -> xmobar-0.30.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/changelog.md new/xmobar-0.30/changelog.md --- old/xmobar-0.29.5/changelog.md 2019-03-17 01:02:36.000000000 +0100 +++ new/xmobar-0.30/changelog.md 2019-08-23 03:22:33.000000000 +0200 @@ -1,3 +1,18 @@ +## Version 0.30 (August, 2019) + +_New features_ + + - New monitor `MultiCoreTemp`, thanks to Felix Springer. + - `DiskIO`: Additional template variables for absolute number of + bytes rather than speeds (see [issue #390]. + - `WeatherX`: An extension to the `Weather` monitor allowing the + spefication of custom strings or icons for sky conditions. + - The battery monitors accept the new arguments `-a` and `-A` to + specify a system command executed if battery left goes beyond a + given threshold. + +[issue #390]: https://github.com/jaor/xmobar/issues/390 + ## Version 0.29.5 (March, 2019) _Bug fixes_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/readme.md new/xmobar-0.30/readme.md --- old/xmobar-0.29.5/readme.md 2019-03-17 01:04:17.000000000 +0100 +++ new/xmobar-0.30/readme.md 2019-07-24 02:32:36.000000000 +0200 @@ -11,9 +11,14 @@ features, like dynamic color management, icons, output templates, and extensibility through plugins. -[This screenshot](doc/xmobar-sawfish.png) shows xmobar running under -[sawfish], and [this one](doc/xmobar-xmonad.png) is a desktop with -[xmonad] and two instances of xmobar. +These are two xmobar instances using the author's configuration: + + + + + +and [this one](doc/xmobar-xmonad.png) is a full desktop with [xmonad] +and, again, two instances of xmobar. [xmonad]: http://xmonad.org [Ion3]: http://tuomov.iki.fi/software/ @@ -739,6 +744,39 @@ - Default template: `<station>: <tempC>C, rh <rh>% (<hour>)` - Retrieves weather information from http://tgftp.nws.noaa.gov. +### `WeatherX StationID SkyConditions Args RefreshRate` + +- Works in the same way as `Weather`, but takes an additional + argument, a list of pairs from sky conditions to their replacement + (typically a unicode string or an icon specification). +- Use the variable `skyConditionS` to display the replacement of the + corresponding sky condition. All other `Weather` template variables + are available as well. + +For example: + +```haskell + WeatherX "LEBL" + [ ("clear", "🌣") + , ("sunny", "🌣") + , ("mostly clear", "🌤") + , ("mostly sunny", "🌤") + , ("partly sunny", "⛅") + , ("fair", "🌑") + , ("cloudy","☁") + , ("overcast","☁") + , ("partly cloudy", "⛅") + , ("mostly cloudy", "🌧") + , ("considerable cloudiness", "⛈")] + ["-t", "<fn=2><skyConditionS></fn> <tempC>° <rh>% <windKmh> (<hour>)" + , "-L","10", "-H", "25", "--normal", "black" + , "--high", "lightgoldenrod4", "--low", "darkseagreen4"] + 18000 +``` + +As mentioned, the replacement string can also be an icon +specification, such as `("clear", "<icon=weather-clear.xbm/>")`. + ### `Network Interface Args RefreshRate` - Aliases to the interface name: so `Network "eth0" []` can be used as @@ -865,6 +903,12 @@ - `-p`: color to display positive power (battery charging) - `-f`: file in `/sys/class/power_supply` with AC info (default: "AC/online") + - `-A`: a number between 0 and 100, threshold below which the action + given by `-a`, if any, is performed (default: 5) + - `-a`: a string with a system command that is run when the + percentage left in the battery is less or equal than the threshold + given by the `-A` option. If not present, no action is + undertaken. - `--on-icon-pattern`: dynamic string for current battery charge when AC is "on" in `leftipat`. - `--off-icon-pattern`: dynamic string for current battery charge @@ -883,14 +927,18 @@ "-L", "10", "-H", "80", "-p", "3", "--", "-O", "<fc=green>On</fc> - ", "-i", "", "-L", "-15", "-H", "-5", - "-l", "red", "-m", "blue", "-h", "green"] + "-l", "red", "-m", "blue", "-h", "green" + "-a", "notify-send -u critical 'Battery running out!!'", + "-A", "3"] 600 In the above example, the thresholds before the "--" separator affect only the `<left>` and `<leftbar>` fields, while those after the separator affect how `<watts>` is displayed. For this monitor, neither the generic nor the specific options have any effect on - `<timeleft>`. + `<timeleft>`. We are also telling the monitor to execute the unix + command `notify-send` when the percentage left in the battery + reaches 6%. It is also possible to specify template variables in the `-O` and `-o` switches, as in the following example: @@ -964,11 +1012,15 @@ - Aliases to `diskio` - Disks: list of pairs of the form (device or mount point, template), - where the template can contain `<total>`, `<read>`, `<write>` for total, - read and write speed, respectively. There are also bar versions of each: - `<totalbar>`, `<totalvbar>`, `<totalipat>`, - `<readbar>`, `<readvbar>`, `<readipat>`, - `<writebar>`, `<writevbar>`, and `<writeipat>`. + where the template can contain `<total>`, `<read>`, `<write>` for + total, read and write speed, respectively, as well as `<totalb>`, + `<readb>`, `<writeb>`, which report number of bytes during the last + refresh period rather than speed. There are also bar versions of + each: `<totalbar>`, `<totalvbar>`, `<totalipat>`, `<readbar>`, + `<readvbar>`, `<readipat>`, `<writebar>`, `<writevbar>`, and + `<writeipat>`; and their "bytes" counterparts: `<totalbbar>`, + `<totalbvbar>`, `<totalbipat>`, `<readbbar>`, `<readbvbar>`, + `<readbipat>`, `<writebbar>`, `<writebvbar>`, and `<writebipat>`. - Thresholds refer to speed in b/s - Args: default monitor arguments. `-t`/`--template` is ignored. Plus - `--total-icon-pattern`: dynamic string for total disk I/O in `<totalipat>`. @@ -1042,6 +1094,34 @@ "-L", "40", "-H", "60", "-l", "lightblue", "-n", "gray90", "-h", "red"] 50 +### `MultiCoreTemp Args RefreshRate` + +- Aliases to `multicoretemp` +- Args: default monitor arguments, plus: + - `--max-icon-pattern`: dynamic string for overall cpu load in `maxipat`. + - `--avg-icon-pattern`: dynamic string for overall cpu load in `avgipat`. + - `--mintemp`: temperature in degree Celsius, that sets the lower + limit for percentage calculation. + - `--maxtemp`: temperature in degree Celsius, that sets the upper + limit for percentage calculation. +- Thresholds refer to temperature in degree Celsius +- Variables that can be used with the `-t`/`--template` argument: + `max`, `maxpc`, `maxbar`, `maxvbar`, `maxipat`, + `avg`, `avgpc`, `avgbar`, `avgvbar`, `avgipat`, + `core0`, `core1`, ..., `coreN` + + The *pc, *bar, *vbar and *ipat variables are showing percentages on the scale + defined by `--mintemp` and `--maxtemp`. + The max* and avg* variables to the highest and the average core temperature. +- Default template: `Temp: <max>°C - <maxpc>%` +- This monitor requires coretemp module to be loaded in kernel +- Example: + + Run MultiCoreTemp ["-t", "Temp: <avg>°C | <avgpc>%", + "-L", "60", "-H", "80", + "-l", "green", "-n", "yellow", "-h", "red" + "--", "--mintemp", "20", "--maxtemp", "100"] 50 + ### `Volume Mixer Element Args RefreshRate` - Aliases to the mixer name and element name separated by a colon. Thus, @@ -1467,15 +1547,15 @@ `start` must receive a callback to be used to display the `String` produced by the plugin. This method can be used for plugins that need -to perform asynchronous actions. See `Plugins/PipeReader.hs` for an -example. +to perform asynchronous actions. See +`src/Xmobar/Plugins/PipeReader.hs` for an example. `run` can be used for simpler plugins. If you define only `run` the plugin will be run every second. To overwrite this default you just need to implement `rate`, which must return the number of tenth of -seconds between every successive runs. See `Plugins/HelloWorld.hs` for -an example of a plugin that runs just once, and `Plugins/Date.hs` for -one that implements `rate`. +seconds between every successive runs. See `examples/xmobar.hs` for an +example of a plugin that runs just once, and +`src/Xmobar/Plugins/Date.hs` for one that implements `rate`. Notice that Date could be implemented as: @@ -1504,8 +1584,8 @@ To use your new plugin, you need to use a pure Haskell configuration for xmobar, and load your definitions there. You can see an example -in [examples/xmobar.hs] showing you how to write a Haskell -configuration that uses a new plugin, all in one file. +in [examples/xmobar.hs](./examples/xmobar.hs) showing you how to write +a Haskell configuration that uses a new plugin, all in one file. When xmobar runs with the full path to that Haskell file as its argument (or if you put it in `~/.config/xmobar/xmobar.hs`), and with @@ -1514,6 +1594,13 @@ That's it! +## Configurations written in pure Haskell + +xmobar can be used as a pure Haskell program, that is compiled with +your specific configuration, expressed as Haskell source code. For an +example, see [the author's +configuration](https://gitlab.com/jaor/xmobar-config/). + # Authors and credits Andrea Rossato originally designed and implemented xmobar up to @@ -1532,10 +1619,10 @@ Petersen, Alexander Polakov, Pavan Rikhi, Petr Rockai, Andrew Sackville-West, Markus Scherer, Daniel Schüssler, Olivier Schneider, Alexander Shabalin, Valentin Shirokov, Peter Simons, Alexander -Solovyov, Will Song, John Soros, Travis Staton, Artem Tarasov, Samuli -Thomasson, Edward Tjörnhammar, Sergei Trofimovich, Thomas Tuegel, Jan -Vornberger, Anton Vorontsov, Daniel Wagner, Zev Weiss, Phil Xiaojun -Hu, Edward Z. Yang and Norbert Zeh. +Solovyov, Will Song, John Soros, Felix Springer, Travis Staton, Artem +Tarasov, Samuli Thomasson, Edward Tjörnhammar, Sergei Trofimovich, +Thomas Tuegel, Jan Vornberger, Anton Vorontsov, Daniel Wagner, Zev +Weiss, Phil Xiaojun Hu, Edward Z. Yang and Norbert Zeh. [jao]: http://jao.io [incorporates patches]: http://www.ohloh.net/p/xmobar/contributors @@ -1572,7 +1659,7 @@ This software is released under a BSD-style license. See [LICENSE] for more details. -Copyright © 2010-2018 Jose Antonio Ortega Ruiz +Copyright © 2010-2019 Jose Antonio Ortega Ruiz Copyright © 2007-2010 Andrea Rossato diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/src/Xmobar/App/Opts.hs new/xmobar-0.30/src/Xmobar/App/Opts.hs --- old/xmobar-0.29.5/src/Xmobar/App/Opts.hs 2018-12-09 04:32:01.000000000 +0100 +++ new/xmobar-0.30/src/Xmobar/App/Opts.hs 2019-03-17 01:10:55.000000000 +0100 @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- | -- Module: Xmobar.App.Opts --- Copyright: (c) 2018 Jose Antonio Ortega Ruiz +-- Copyright: (c) 2018, 2019 Jose Antonio Ortega Ruiz -- License: BSD3-style (see LICENSE) -- -- Maintainer: [email protected] @@ -105,7 +105,7 @@ info :: String info = "xmobar " ++ showVersion version ++ "\n (C) 2007 - 2010 Andrea Rossato " - ++ "\n (C) 2010 - 2018 Jose A Ortega Ruiz\n " + ++ "\n (C) 2010 - 2019 Jose A Ortega Ruiz\n " ++ mail ++ "\n" ++ license mail :: String diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/Batt.hs new/xmobar-0.30/src/Xmobar/Plugins/Monitors/Batt.hs --- old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/Batt.hs 2018-12-02 06:14:36.000000000 +0100 +++ new/xmobar-0.30/src/Xmobar/Plugins/Monitors/Batt.hs 2019-06-30 06:10:19.000000000 +0200 @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Batt --- Copyright : (c) 2010, 2011, 2012, 2013, 2015, 2016, 2018 Jose A Ortega +-- Copyright : (c) 2010, 2011, 2012, 2013, 2015, 2016, 2018, 2019 Jose A Ortega -- (c) 2010 Andrea Rossato, Petr Rockai -- License : BSD-style (see LICENSE) -- @@ -15,6 +15,8 @@ module Xmobar.Plugins.Monitors.Batt ( battConfig, runBatt, runBatt' ) where +import System.Process (system) +import Control.Monad (void, unless) import Control.Exception (SomeException, handle) import Xmobar.Plugins.Monitors.Common import System.FilePath ((</>)) @@ -36,6 +38,8 @@ , highWColor :: Maybe String , lowThreshold :: Float , highThreshold :: Float + , onLowAction :: Maybe String + , actionThreshold :: Float , onlineFile :: FilePath , scale :: Float , onIconPattern :: Maybe IconPattern @@ -52,6 +56,8 @@ , lowWColor = Nothing , mediumWColor = Nothing , highWColor = Nothing + , onLowAction = Nothing + , actionThreshold = 6 , lowThreshold = 10 , highThreshold = 12 , onlineFile = "AC/online" @@ -74,6 +80,9 @@ , Option "H" ["hight"] (ReqArg (\x o -> o { highThreshold = read x }) "") "" , 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 "A" ["action-threshold"] + (ReqArg (\x o -> o { actionThreshold = read x }) "") "" , Option "" ["on-icon-pattern"] (ReqArg (\x o -> o { onIconPattern = Just $ parseIconPattern x }) "") "" , Option "" ["off-icon-pattern"] (ReqArg (\x o -> @@ -172,6 +181,13 @@ mostCommonDef :: Eq a => a -> [a] -> a mostCommonDef x xs = head $ last $ [x] : sortOn length (group xs) +maybeAlert :: BattOpts -> Float -> IO () +maybeAlert opts left = + case onLowAction opts of + Nothing -> return () + Just x -> unless (isNaN left || actionThreshold opts < 100 * left) + $ void $ system x + readBatteries :: BattOpts -> [Files] -> IO Result readBatteries opts bfs = do let bfs' = filter (/= NoFiles) bfs @@ -192,6 +208,7 @@ | time == 0 = Idle | ac = Charging | otherwise = Discharging + unless ac (maybeAlert opts left) return $ if isNaN left then NA else Result left watts time racst runBatt :: [String] -> Monitor String @@ -209,7 +226,8 @@ do l <- fmtPercent x ws <- fmtWatts w opts suffix d si <- getIconPattern opts s x - parseTemplate (l ++ [fmtStatus opts s nas, fmtTime $ floor t, ws, si]) + st <- showWithColors' (fmtStatus opts s nas) (100 * x) + parseTemplate (l ++ [st, fmtTime $ floor t, ws, si]) NA -> getConfigValue naString where fmtPercent :: Float -> Monitor [String] fmtPercent x = do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/Disk.hs new/xmobar-0.30/src/Xmobar/Plugins/Monitors/Disk.hs --- old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/Disk.hs 2018-12-02 06:15:08.000000000 +0100 +++ new/xmobar-0.30/src/Xmobar/Plugins/Monitors/Disk.hs 2019-05-23 18:44:52.000000000 +0200 @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Disk --- Copyright : (c) 2010, 2011, 2012, 2014, 2018 Jose A Ortega Ruiz +-- Copyright : (c) 2010, 2011, 2012, 2014, 2018, 2019 Jose A Ortega Ruiz -- License : BSD-style (see LICENSE) -- -- Maintainer : Jose A Ortega Ruiz <[email protected]> @@ -54,9 +54,13 @@ diskIOConfig :: IO MConfig diskIOConfig = mkMConfig "" ["total", "read", "write" + ,"totalb", "readb", "writeb" ,"totalbar", "readbar", "writebar" + ,"totalbbar", "readbbar", "writebbar" ,"totalvbar", "readvbar", "writevbar" + ,"totalbvbar", "readbvbar", "writebvbar" ,"totalipat", "readipat", "writeipat" + ,"totalbipat", "readbipat", "writebipat" ] data DiskUOpts = DiskUOpts @@ -148,11 +152,16 @@ case find ((==dev) . fst) dat of Nothing -> (dev, [0, 0, 0]) Just (_, xs) -> - let rSp = speed (xs !! 2) (xs !! 3) - wSp = speed (xs !! 6) (xs !! 7) - sp = speed (xs !! 2 + xs !! 6) (xs !! 3 + xs !! 7) - speed x t = if t == 0 then 0 else 500 * x / t - dat' = if length xs > 6 then [sp, rSp, wSp] else [0, 0, 0] + let r = xs !! 2 + w = xs !! 6 + t = r + w + rSp = speed r (xs !! 3) + wSp = speed w (xs !! 7) + sp = speed t (xs !! 3 + xs !! 7) + speed x d = if d == 0 then 0 else 500 * x / d + dat' = if length xs > 6 + then [sp, rSp, wSp, t, r, w] + else [0, 0, 0, 0, 0, 0] in (dev, dat') speedToStr :: Float -> String @@ -184,7 +193,9 @@ b <- mapM (showLogBar 0.8) xs vb <- mapM (showLogVBar 0.8) xs ipat <- mapM (\(f,v) -> showLogIconPattern (f opts) 0.8 v) - $ zip [totalIconPattern, readIconPattern, writeIconPattern] xs + $ zip [totalIconPattern, readIconPattern, writeIconPattern + , totalIconPattern, readIconPattern, writeIconPattern] + xs setConfigValue tmp template parseTemplate $ s ++ b ++ vb ++ ipat diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/Mpris.hs new/xmobar-0.30/src/Xmobar/Plugins/Monitors/Mpris.hs --- old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/Mpris.hs 2018-11-22 00:52:35.000000000 +0100 +++ new/xmobar-0.30/src/Xmobar/Plugins/Monitors/Mpris.hs 2019-06-30 01:53:42.000000000 +0200 @@ -85,7 +85,7 @@ runMPRIS :: (MprisVersion a) => a -> String -> [String] -> Monitor String runMPRIS version playerName _ = do metadata <- io $ getMetadata version dbusClient playerName - if [] == metadata then + if null metadata then getConfigValue naString else mapM showWithPadding (makeList version metadata) >>= parseTemplate diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs new/xmobar-0.30/src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs --- old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/xmobar-0.30/src/Xmobar/Plugins/Monitors/MultiCoreTemp.hs 2019-07-15 01:51:55.000000000 +0200 @@ -0,0 +1,165 @@ +----------------------------------------------------------------------------- +-- | +-- Module : Plugins.Monitors.MultiCoreTemp +-- Copyright : (c) 2019 Felix Springer +-- License : BSD-style (see LICENSE) +-- +-- Maintainer : Felix Springer <[email protected]> +-- Stability : unstable +-- Portability : unportable +-- +-- A core temperature monitor for Xmobar +-- +----------------------------------------------------------------------------- + +module Xmobar.Plugins.Monitors.MultiCoreTemp (startMultiCoreTemp) where + +import Xmobar.Plugins.Monitors.Common +import Control.Monad (filterM) +import System.Console.GetOpt +import System.Directory ( doesDirectoryExist + , doesFileExist + ) + +-- | Declare Options. +data CTOpts = CTOpts { maxIconPattern :: Maybe IconPattern + , avgIconPattern :: Maybe IconPattern + , mintemp :: Float + , maxtemp :: Float + } + +-- | Set default Options. +defaultOpts :: CTOpts +defaultOpts = CTOpts { maxIconPattern = Nothing + , avgIconPattern = Nothing + , mintemp = 0 + , maxtemp = 100 + } + +-- | Apply configured Options. +options :: [OptDescr (CTOpts -> CTOpts)] +options = [ Option [] ["max-icon-pattern"] + (ReqArg + (\ arg opts -> opts { maxIconPattern = Just $ parseIconPattern arg }) + "") + "" + , Option [] ["avg-icon-pattern"] + (ReqArg + (\ arg opts -> opts { avgIconPattern = Just $ parseIconPattern arg }) + "") + "" + , Option [] ["mintemp"] + (ReqArg + (\ arg opts -> opts { mintemp = read arg }) + "") + "" + , Option [] ["maxtemp"] + (ReqArg + (\ arg opts -> opts { maxtemp = read arg }) + "") + "" + ] + +-- | Parse Arguments and apply them to Options. +parseOpts :: [String] -> IO CTOpts +parseOpts argv = case getOpt Permute options argv of + (opts , _ , [] ) -> return $ foldr id defaultOpts opts + (_ , _ , errs) -> ioError . userError $ concat errs + +-- | Generate Config with a default template and options. +cTConfig :: IO MConfig +cTConfig = mkMConfig cTTemplate cTOptions + where cTTemplate = "Temp: <max>°C - <maxpc>%" + cTOptions = [ "max" , "maxpc" , "maxbar" , "maxvbar" , "maxipat" + , "avg" , "avgpc" , "avgbar" , "avgvbar" , "avgipat" + ] ++ map (("core" ++) . show) [0 :: Int ..] + +-- | Returns the first coretemp.N path found. +coretempPath :: IO String +coretempPath = do xs <- filterM doesDirectoryExist ps + let x = head xs + return x + where ps = [ "/sys/bus/platform/devices/coretemp." ++ show (x :: Int) ++ "/" | x <- [0..9] ] + +-- | Returns the first hwmonN path found. +hwmonPath :: IO String +hwmonPath = do p <- coretempPath + xs <- filterM doesDirectoryExist [ p ++ "hwmon/hwmon" ++ show (x :: Int) ++ "/" | x <- [0..9] ] + let x = head xs + return x + +-- | Checks Labels, if they refer to a core and returns Strings of core- +-- temperatures. +corePaths :: IO [String] +corePaths = do p <- hwmonPath + ls <- filterM doesFileExist [ p ++ "temp" ++ show (x :: Int) ++ "_label" | x <- [0..9] ] + cls <- filterM isLabelFromCore ls + return $ map labelToCore cls + +-- | Checks if Label refers to a core. +isLabelFromCore :: FilePath -> IO Bool +isLabelFromCore p = do a <- readFile p + return $ take 4 a == "Core" + +-- | Transform a path to Label to a path to core-temperature. +labelToCore :: FilePath -> FilePath +labelToCore = (++ "input") . reverse . drop 5 . reverse + +-- | Reads core-temperatures as data from the system. +cTData :: IO [Float] +cTData = do fps <- corePaths + traverse readSingleFile fps + where readSingleFile :: FilePath -> IO Float + readSingleFile s = do a <- readFile s + return $ parseContent a + where parseContent :: String -> Float + parseContent = read . head . lines + +-- | Transforms data of temperatures into temperatures of degree Celsius. +parseCT :: IO [Float] +parseCT = do rawCTs <- cTData + let normalizedCTs = map (/ 1000) rawCTs :: [Float] + return normalizedCTs + +-- | Performs calculation for maximum and average. +-- Sets up Bars and Values to be printed. +formatCT :: CTOpts -> [Float] -> Monitor [String] +formatCT opts cTs = do let CTOpts { mintemp = minT + , maxtemp = maxT } = opts + domainT = maxT - minT + maxCT = maximum cTs + avgCT = sum cTs / fromIntegral (length cTs) + calcPc t = (t - minT) / domainT + maxCTPc = calcPc maxCT + avgCTPc = calcPc avgCT + + cs <- traverse showTempWithColors cTs + + m <- showTempWithColors maxCT + mp <- showWithColors' (show (round (100*maxCTPc) :: Int)) maxCT + mb <- showPercentBar maxCT maxCTPc + mv <- showVerticalBar maxCT maxCTPc + mi <- showIconPattern (maxIconPattern opts) maxCTPc + + a <- showTempWithColors avgCT + ap <- showWithColors' (show (round (100*avgCTPc) :: Int)) avgCT + ab <- showPercentBar avgCT avgCTPc + av <- showVerticalBar avgCT avgCTPc + ai <- showIconPattern (avgIconPattern opts) avgCTPc + + let ms = [ m , mp , mb , mv , mi ] + as = [ a , ap , ab , av , ai ] + + return (ms ++ as ++ cs) + where showTempWithColors :: Float -> Monitor String + showTempWithColors = showWithColors (show . (round :: Float -> Int)) + + +runCT :: [String] -> Monitor String +runCT argv = do cTs <- io parseCT + opts <- io $ parseOpts argv + l <- formatCT opts cTs + parseTemplate l + +startMultiCoreTemp :: [String] -> Int -> (String -> IO ()) -> IO () +startMultiCoreTemp a = runM a cTConfig runCT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/Weather.hs new/xmobar-0.30/src/Xmobar/Plugins/Monitors/Weather.hs --- old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors/Weather.hs 2019-02-07 05:36:40.000000000 +0100 +++ new/xmobar-0.30/src/Xmobar/Plugins/Monitors/Weather.hs 2019-06-29 19:34:08.000000000 +0200 @@ -23,6 +23,7 @@ import Network.HTTP.Types.Status import Network.HTTP.Types.Method import qualified Data.ByteString.Lazy.Char8 as B +import Data.Char (toLower) import Text.ParserCombinators.Parsec @@ -43,6 +44,7 @@ , "windMs" , "visibility" , "skyCondition" + , "skyConditionS" , "tempC" , "tempF" , "dewPointC" @@ -194,18 +196,28 @@ where errHandler :: CE.SomeException -> IO String errHandler _ = return "<Could not retrieve data>" -formatWeather :: [WeatherInfo] -> Monitor String -formatWeather [WI st ss y m d h (WindInfo wc wa wm wk wkh wms) v sk tC tF dC dF r p] = +formatSk :: Eq p => [(p, p)] -> p -> p +formatSk ((a,b):sks) sk = if a == sk then b else formatSk sks sk +formatSk [] sk = sk + +formatWeather :: [(String,String)] -> [WeatherInfo] -> Monitor String +formatWeather sks [WI st ss y m d h (WindInfo wc wa wm wk wkh wms) v sk tC tF dC dF r p] = do cel <- showWithColors show tC far <- showWithColors show tF - parseTemplate [st, ss, y, m, d, h, wc, wa, wm, wk, wkh, wms, v, sk, cel, far, show dC, show dF, show r , show p ] -formatWeather _ = getConfigValue naString + let sk' = formatSk sks (map toLower sk) + parseTemplate [st, ss, y, m, d, h, wc, wa, wm, wk, wkh + , wms, v, sk, sk', cel, far + , show dC, show dF, show r , show p ] +formatWeather _ _ = getConfigValue naString runWeather :: [String] -> Monitor String -runWeather str = - do d <- io $ getData $ head str +runWeather = runWeather' [] + +runWeather' :: [(String, String)] -> [String] -> Monitor String +runWeather' sks args = + do d <- io $ getData $ head args i <- io $ runP parseData d - formatWeather i + formatWeather sks i weatherReady :: [String] -> Monitor Bool weatherReady str = do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors.hs new/xmobar-0.30/src/Xmobar/Plugins/Monitors.hs --- old/xmobar-0.29.5/src/Xmobar/Plugins/Monitors.hs 2018-12-02 06:35:07.000000000 +0100 +++ new/xmobar-0.30/src/Xmobar/Plugins/Monitors.hs 2019-07-15 01:51:55.000000000 +0200 @@ -3,7 +3,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Xmobar.Plugins.Monitors --- Copyright : (c) 2010, 2011, 2012, 2013, 2017, 2018 Jose Antonio Ortega Ruiz +-- Copyright : (c) 2010, 2011, 2012, 2013, 2017, 2018, 2019 Jose Antonio Ortega Ruiz -- (c) 2007-10 Andrea Rossato -- License : BSD-style (see LICENSE) -- @@ -34,6 +34,7 @@ import Xmobar.Plugins.Monitors.ThermalZone import Xmobar.Plugins.Monitors.CpuFreq import Xmobar.Plugins.Monitors.CoreTemp +import Xmobar.Plugins.Monitors.MultiCoreTemp import Xmobar.Plugins.Monitors.Disk import Xmobar.Plugins.Monitors.Top import Xmobar.Plugins.Monitors.Uptime @@ -72,12 +73,14 @@ | Brightness Args Rate | CpuFreq Args Rate | CoreTemp Args Rate + | MultiCoreTemp Args Rate | TopProc Args Rate | TopMem Args Rate | Uptime Args Rate | CatInt Int FilePath Args Rate #ifdef WEATHER | Weather Station Args Rate + | WeatherX Station SkyConditions Args Rate #endif #ifdef UVMETER | UVMeter Station Args Rate @@ -103,6 +106,7 @@ type Program = String type Alias = String type Station = String +type SkyConditions = [(String, String)] type Zone = String type ZoneNo = Int type Interface = String @@ -112,6 +116,7 @@ instance Exec Monitors where #ifdef WEATHER alias (Weather s _ _) = s + alias (WeatherX s _ _ _) = s #endif alias (Network i _ _) = i alias (DynNetwork _ _) = "dynnetwork" @@ -129,6 +134,7 @@ alias (TopProc _ _) = "top" alias (TopMem _ _) = "topmem" alias (CoreTemp _ _) = "coretemp" + alias (MultiCoreTemp _ _) = "multicoretemp" alias DiskU {} = "disku" alias DiskIO {} = "diskio" alias (Uptime _ _) = "uptime" @@ -159,6 +165,7 @@ start (TopMem a r) = runM a topMemConfig runTopMem r #ifdef WEATHER start (Weather s a r) = runMD (a ++ [s]) weatherConfig runWeather r weatherReady + start (WeatherX s c a r) = runMD (a ++ [s]) weatherConfig (runWeather' c) r weatherReady #endif start (Thermal z a r) = runM (a ++ [z]) thermalConfig runThermal r start (ThermalZone z a r) = @@ -171,6 +178,7 @@ start (Brightness a r) = runM a brightConfig runBright r start (CpuFreq a r) = runM a cpuFreqConfig runCpuFreq r start (CoreTemp a r) = runM a coreTempConfig runCoreTemp r + start (MultiCoreTemp a r) = startMultiCoreTemp a r start (DiskU s a r) = runM a diskUConfig (runDiskU s) r start (DiskIO s a r) = startDiskIO s a r start (Uptime a r) = runM a uptimeConfig runUptime r diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/src/Xmobar/X11/Parsers.hs new/xmobar-0.30/src/Xmobar/X11/Parsers.hs --- old/xmobar-0.29.5/src/Xmobar/X11/Parsers.hs 2018-11-25 23:33:53.000000000 +0100 +++ new/xmobar-0.30/src/Xmobar/X11/Parsers.hs 2019-06-30 18:04:41.000000000 +0200 @@ -55,7 +55,7 @@ -> Parser [[(Widget, ColorString, FontIndex, Maybe [Action])]] stringParser c f a = manyTill (allParsers c f a) eof --- | Parses a maximal string without color markup. +-- | Parses a maximal string without markup. textParser :: String -> FontIndex -> Maybe [Action] -> Parser [(Widget, ColorString, FontIndex, Maybe [Action])] textParser c f a = do s <- many1 $ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.29.5/xmobar.cabal new/xmobar-0.30/xmobar.cabal --- old/xmobar-0.29.5/xmobar.cabal 2019-02-07 05:35:20.000000000 +0100 +++ new/xmobar-0.30/xmobar.cabal 2019-08-23 03:23:28.000000000 +0200 @@ -1,5 +1,5 @@ name: xmobar -version: 0.29.5 +version: 0.30 homepage: http://xmobar.org synopsis: A Minimalistic Text Based Status Bar description: Xmobar is a minimalistic text based status bar. @@ -143,6 +143,7 @@ Xmobar.Plugins.Monitors.Cpu, Xmobar.Plugins.Monitors.Disk, Xmobar.Plugins.Monitors.Mem, + Xmobar.Plugins.Monitors.MultiCoreTemp, Xmobar.Plugins.Monitors.MultiCpu, Xmobar.Plugins.Monitors.Net, Xmobar.Plugins.Monitors.Swap,
