Hello community, here is the log from the commit of package xmobar for openSUSE:Factory checked in at 2016-08-25 09:57:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/xmobar (Old) and /work/SRC/openSUSE:Factory/.xmobar.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "xmobar" Changes: -------- --- /work/SRC/openSUSE:Factory/xmobar/xmobar.changes 2016-07-21 08:01:21.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.xmobar.new/xmobar.changes 2016-08-25 09:57:34.000000000 +0200 @@ -1,0 +2,15 @@ +Wed Aug 17 18:43:13 UTC 2016 - psim...@suse.com + +- Update to version 0.24.2 revision 0 with cabal2obs. + +------------------------------------------------------------------- +Mon Aug 1 14:07:12 UTC 2016 - psim...@suse.com + +- Update to version 0.24.1 revision 0 with cabal2obs. + +------------------------------------------------------------------- +Thu Jul 28 11:31:07 UTC 2016 - psim...@suse.com + +- Update to version 0.24 revision 0 with cabal2obs. + +------------------------------------------------------------------- Old: ---- xmobar-0.23.1.tar.gz New: ---- xmobar-0.24.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ xmobar.spec ++++++ --- /var/tmp/diff_new_pack.MRRb9h/_old 2016-08-25 09:57:36.000000000 +0200 +++ /var/tmp/diff_new_pack.MRRb9h/_new 2016-08-25 09:57:36.000000000 +0200 @@ -17,7 +17,7 @@ Name: xmobar -Version: 0.23.1 +Version: 0.24.2 Release: 0 Summary: A Minimalistic Text Based Status Bar License: BSD-3-Clause @@ -25,13 +25,15 @@ Url: https://hackage.haskell.org/package/%{name} Source0: https://hackage.haskell.org/package/%{name}-%{version}/%{name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel -# Begin cabal-rpm deps: BuildRequires: ghc-HTTP-devel BuildRequires: ghc-X11-devel +BuildRequires: ghc-X11-xft-devel BuildRequires: ghc-bytestring-devel BuildRequires: ghc-containers-devel +BuildRequires: ghc-dbus-devel BuildRequires: ghc-directory-devel BuildRequires: ghc-filepath-devel +BuildRequires: ghc-hinotify-devel BuildRequires: ghc-mtl-devel BuildRequires: ghc-old-locale-devel BuildRequires: ghc-parsec-devel @@ -43,15 +45,11 @@ BuildRequires: ghc-transformers-devel BuildRequires: ghc-unix-devel BuildRequires: ghc-utf8-string-devel +BuildRequires: libXpm-devel +BuildRequires: libXrandr-devel +BuildRequires: libXrender-devel BuildRequires: libiw-devel -BuildRequires: pkgconfig -BuildRequires: pkgconfig(xpm) -BuildRequires: pkgconfig(xrandr) BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: ghc-X11-xft-devel -BuildRequires: ghc-dbus-devel -BuildRequires: ghc-hinotify-devel -BuildRequires: libXinerama-devel %description Xmobar is a minimalistic text based status bar. @@ -63,13 +61,12 @@ %setup -q %build -%define cabal_configure_options -f"with_thread with_utf8 with_xft with_xpm with_mpris with_dbus with_iwlib with_inotify" +%define cabal_configure_options -fwith_thread -fwith_utf8 -fwith_xft -fwith_xpm -fwith_mpris -fwith_dbus -fwith_iwlib -fwith_inotify %ghc_bin_build %install %ghc_bin_install - %files %defattr(-,root,root,-) %doc license ++++++ xmobar-0.23.1.tar.gz -> xmobar-0.24.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/news.md new/xmobar-0.24.2/news.md --- old/xmobar-0.23.1/news.md 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/news.md 2016-08-08 23:40:59.000000000 +0200 @@ -1,5 +1,58 @@ % xmobar - Release notes +## Version 0.24.2 (Aug 8, 2016) + +_Bug fixes_ + + - New Weather plugin URL (see [issue #270]). + +[issue #270]: https://github.com/jaor/xmobar/issues/270 + +## Version 0.24.1 (Jul 28, 2016) + +_Bug fixes_ + + - Restoring compatibility with GHC 7.6, (see [issue #269]). + +[issue #269]: https://github.com/jaor/xmobar/issues/269 + +## Version 0.24 (Jul 26, 2016) + +_New features_ + + - Use the new compilation flag `with_conduit` to compile an + implemetation of the `Weather` plugin that will work behind + proxies, by Dragos Boca. + - New command line argument (`-p`) to specify xmobar's position, by + Valentin Shirokov. + - Wind speed in Km/h and m/s for the `Weather` plugin, by Michael + Knabe. + - `UVMeter`, a new optional plugin showing UV data for Australian + users, by Roman Joost. + - New template parameter `<date>` for the `MPD` plugin (by Bruno + Heridet) + - New monitor argument `-T` to specify the maximum total width of + the monitor text. + - New $VAR parameter syntax for using env vars in pipe monitors, by + Will Song (see [issue #268]). + +_Bug fixes_ + + - The `Volume` plugin now supports capture devices (Antoine Eiche). + - The `MPD` plugin will now automatically update on options changes + (Ben Boeckel). + - The `Battery` plugin does now a better job at tracking AC status + and times (see [issue #231]). + - `PipeReader` was polling too often (thanks to zlbruce). + - The `MPris` monitor now honours field width and padding optons + (-M, -w, etc.). + - `Batt`: sensible thresholds for high/low power consumption (see + [issue #265]). + +[issue #231]: https://github.com/jaor/xmobar/issues/225 +[issue #265]: https://github.com/jaor/xmobar/issues/225 +[issue #268]: https://github.com/jaor/xmobar/issues/268 + ## Version 0.23.1 (Apr 14, 2015) _Bug fixes_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/readme.md new/xmobar-0.24.2/readme.md --- old/xmobar-0.23.1/readme.md 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/readme.md 2016-08-08 23:40:59.000000000 +0200 @@ -10,7 +10,7 @@ features, like dynamic color management, icons, output templates, and extensibility through plugins. -This page documents xmobar 0.23.1 (see [release notes]). +This page documents xmobar 0.24.2 (see [release notes]). [This screenshot] shows xmobar running under [sawfish], with antialiased fonts. And [this one] is my desktop with [xmonad] and two @@ -57,7 +57,7 @@ - From [Github]. You can also obtain a tarball in [Github's downloads page]. You'll find there links to each tagged release. - From the bleeding edge repo. If you prefer to live dangerously, - just get the latest and greatest (and buggiest, i guess) using + just get the latest and greatest (and buggiest, I guess) using git: git clone git://github.com/jaor/xmobar @@ -157,6 +157,13 @@ : Support for xpm image file format. This will allow loading .xpm files in `<icon>`. Requires the [libXpm] C library. +`with_uvmeter` +: Enables UVMeter plugin. The plugin shows UV data for Australia. + +`with_conduit` +: Use http-conduit for getting weather data enabling support for http proxies. + Requires [http-conduit] and [http-types]. + `all_extensions` : Enables all the extensions above. @@ -180,7 +187,7 @@ - After receiving SIGUSR1 xmobar moves its position to the next screen. -- After receiving SIGUSR2 xmobar repositions it self on the current screen. +- After receiving SIGUSR2 xmobar repositions itself on the current screen. # Configuration @@ -387,6 +394,7 @@ -A alpha --alpha=alpha The transparency: 0 is transparent, 255 (the default) is opaque -o --top Place xmobar at the top of the screen -b --bottom Place xmobar at the bottom of the screen + -p --position=position Specify position, same as in config file -d --dock Try to start xmobar as a dock -a alignsep --alignsep=alignsep Separators for left, center and right text alignment. Default: '}{' @@ -579,7 +587,7 @@ ### Icon patterns Some monitors allow usage of strings that depend on some integer value -from 0 to 8 by replacing all occurences of `"%%"` with it +from 0 to 8 by replacing all occurrences of `"%%"` with it (i.e. `"<icon=/path/to/icon_%%.xpm/>"` will be interpreted as `"<icon=/path/to/icon_3.xpm/>"` when the value is `3`, also `"%"` is interpreted as `"%"`, `"%%"` as `"3"`, `"%%%"` as `"3%"`, `"%%%%"` as `"33"` and so on). Essentially @@ -674,6 +682,10 @@ needed. - Long option: `--width` - Default: 0 (variable width) +- `-T` _number_ Maximum total width + - Maximum total width of the text. + - Long option: `--maxtwidth` + - Default: 0 (no limit) - `-c` _string_ - Characters used for padding. The characters of _string_ are used cyclically. E.g., with `-P +- -w 6`, a field with value "foo" @@ -735,7 +747,7 @@ - Args: default monitor arguments - Variables that can be used with the `-t`/`--template` argument: `station`, `stationState`, `year`, `month`, `day`, `hour`, - `windCardinal`, `windAzimuth`, `windMph`, `windKnots`, + `windCardinal`, `windAzimuth`, `windMph`, `windKnots`, `windMs`, `windKmh` `visibility`, `skyCondition`, `tempC`, `tempF`, `dewPointC`, `dewPointF`, `rh`, `pressure` - Default template: `<station>: <tempC>C, rh <rh>% (<hour>)` @@ -854,8 +866,8 @@ - `-O`: string for AC "on" status (default: "On") - `-i`: string for AC "idle" status (default: "On") - `-o`: string for AC "off" status (default: "Off") - - `-L`: low power (`watts`) threshold (default: -12) - - `-H`: high power threshold (default: -10) + - `-L`: low power (`watts`) threshold (default: 10) + - `-H`: high power threshold (default: 12) - `-l`: color to display power lower than the `-L` threshold - `-m`: color to display power lower than the `-H` threshold - `-h`: color to display power higher than the `-H` threshold @@ -1089,7 +1101,7 @@ `plength` (playlist length), `ppos` (playlist position), `flags` (ncmpcpp-style playback mode), `name`, `artist`, `composer`, `performer`, - `album`, `title`, `track`, `file`, `genre` + `album`, `title`, `track`, `file`, `genre`, `date` - Default template: `MPD: <state>` - Example (note that you need "--" to separate regular monitor options from MPD's specific ones): @@ -1243,6 +1255,20 @@ Run CatInt 0 "/sys/devices/platform/thinkpad_hwmon/fan1_input" [] 50 +### `UVMeter` + +- Aliases to "uv " + station id. For example: `%uv brisbane%` or `%uv + alice springs%` +- Args: default monitor arguments. + +- *Reminder:* Keep the refresh rate high, to avoid making unnecessary + requests every time the plug-in is run. +- Station IDs can be found here: + http://www.arpansa.gov.au/uvindex/realtime/xml/uvvalues.xml +- Example: + + Run UVMeter "brisbane" ["-H", "3", "-L", "3", "--low", "green", "--high", "red"] 900 + ## Executing External Commands In order to execute an external command you can either write the @@ -1322,6 +1348,7 @@ - Reads its displayed output from the given pipe. - Prefix an optional default text separated by a colon +- Expands environment variables in the first argument of syntax '${VAR}' or '$VAR' <font size="+1">**`MarqueePipeReader "default text:/path/to/pipe" (length, rate, sep) Alias`**</font> @@ -1331,6 +1358,8 @@ Run MarqueePipeReader "/tmp/testpipe" (10, 7, "+") "mpipe" +- Expands environment variables in the first argument + <font size="+1"> **`BufferedPipeReader Alias [(Timeout, Bool, "/path/to/pipe1"), ..]`** </font> @@ -1360,6 +1389,7 @@ `"/tmp/xmobar_status"` will reveal xmonad for 1.5 seconds and temporarily overwrite the window titles. - Take a look at [samples/status.sh] +- Expands environment variables for the pipe path [samples/status.sh]: http://github.com/jaor/xmobar/raw/master/samples/status.sh @@ -1517,19 +1547,20 @@ version 0.11.1. Since then, it is maintained and developed by [jao], with the help of the greater xmobar and Haskell communities. -In particular, xmobar [incorporates patches] by Axel Angel, Ben -Boeckel, Duncan Burke, Roman Cheplyaka, Patrick Chilton, Nathaniel -Wesley Filardo, John Goerzen, Reto Hablützel, Juraj Hercek, Tomas -Janousek, Spencer Janssen, Jochen Keil, Lennart Kolmodin, Krzysztof -Kosciuszkiewicz, Dmitry Kurochkin, Todd Lunter, Robert J. Macomber, -Dmitry Malikov, David McLean, Marcin Mikołajczyk, Dino Morelli, Tony -Morris, Eric Mrak, Thiago Negri, Edward O'Callaghan, Svein Ove, Martin -Perner, Jens Petersen, Alexander Polakov, Petr Rockai, Andrew -Sackville-West, Markus Scherer, Alexander Shabalin, Peter Simons, -Alexander Solovyov, John Soros, Travis Staton, Artem Tarasov, Samuli -Thomasson, Edward Tjörnhammar, Sergei Trofimovich, Thomas Tuegel, Jan -Vornberger, Anton Vorontsov, Daniel Wagner, Phil Xiaojun Hu, Edward -Z. Yang and Norbert Zeh. +In particular, xmobar [incorporates patches] by Axel Angel, Dragos +Boca, Ben Boeckel, Duncan Burke, Roman Cheplyaka, Patrick Chilton, +Antoine Eiche, Nathaniel Wesley Filardo, John Goerzen, Reto Hablützel, +Juraj Hercek, Tomas Janousek, Spencer Janssen, Roman Joost, Jochen +Keil, Lennart Kolmodin, Krzysztof Kosciuszkiewicz, Dmitry Kurochkin, +Todd Lunter, Robert J. Macomber, Dmitry Malikov, David McLean, Marcin +Mikołajczyk, Dino Morelli, Tony Morris, Eric Mrak, Thiago Negri, +Edward O'Callaghan, Svein Ove, Martin Perner, Jens Petersen, Alexander +Polakov, Petr Rockai, Andrew Sackville-West, Markus Scherer, 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, Phil Xiaojun Hu, Edward Z. Yang and +Norbert Zeh. [jao]: http://jao.io [incorporates patches]: http://www.ohloh.net/p/xmobar/contributors @@ -1571,14 +1602,14 @@ This software is released under a BSD-style license. See [LICENSE] for more details. -Copyright © 2010-2014 Jose Antonio Ortega Ruiz +Copyright © 2010-2016 Jose Antonio Ortega Ruiz Copyright © 2007-2010 Andrea Rossato [Github]: http://github.com/jaor/xmobar/ [Github page]: http://github.com/jaor/xmobar [Hackage]: http://hackage.haskell.org/package/xmobar/ -[LICENSE]: https://github.com/jaor/xmobar/raw/master/LICENSE +[LICENSE]: https://github.com/jaor/xmobar/raw/master/license [Mailing list]: http://projects.haskell.org/cgi-bin/mailman/listinfo/xmobar [MPD]: http://mpd.wikia.com/ [X11-xft]: http://hackage.haskell.org/package/X11-xft/ @@ -1597,3 +1628,5 @@ [timezone-olson]: http://hackage.haskell.org/package/timezone-olson [timezone-series]: http://hackage.haskell.org/package/timezone-series [libXpm]: http://cgit.freedesktop.org/xorg/lib/libXpm +[http-conduit]: http://hackage.haskell.org/package/http-conduit +[http-types]: http://hackage.haskell.org/package/http-types diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/samples/xmobar.config new/xmobar-0.24.2/samples/xmobar.config --- old/xmobar-0.23.1/samples/xmobar.config 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/samples/xmobar.config 2016-08-08 23:40:59.000000000 +0200 @@ -1,5 +1,5 @@ Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*" - , addtionalFonts = [] + , additionalFonts = [] , borderColor = "black" , border = TopB , bgColor = "black" @@ -29,7 +29,7 @@ , Run Memory ["-t","Mem: <usedratio>%"] 10 , Run Swap [] 10 , Run Com "uname" ["-s","-r"] "" 36000 - , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10 + , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10 ] , sepChar = "%" , alignSep = "}{" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Environment.hs new/xmobar-0.24.2/src/Environment.hs --- old/xmobar-0.23.1/src/Environment.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/xmobar-0.24.2/src/Environment.hs 2016-08-08 23:40:59.000000000 +0200 @@ -0,0 +1,49 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMobar.Environment +-- Copyright : (c) William Song +-- License : BSD-style (see LICENSE) +-- +-- Maintainer : Will Song <incer...@incertia.net> +-- Stability : stable +-- Portability : portable +-- +-- A function to expand environment variables in strings +-- +----------------------------------------------------------------------------- +module Environment where + +import Control.Applicative ((<$>)) +import Data.Maybe (fromMaybe) +import System.Environment (lookupEnv) + +expandEnv :: String -> IO String +expandEnv "" = return "" +expandEnv (c:s) = case c of + '$' -> do + envVar <- fromMaybe "" <$> lookupEnv e + remainder <- expandEnv s' + return $ envVar ++ remainder + where (e, s') = getVar s + getVar "" = ("", "") + getVar ('{':s'') = (takeUntil "}" s'', drop 1 . dropUntil "}" $ s'') + getVar s'' = (takeUntil filterstr s'', dropUntil filterstr s'') + filterstr = ",./? \t;:\"'~`!@#$%^&*()<>-+=\\|" + takeUntil f = takeWhile (not . flip elem f) + dropUntil f = dropWhile (not . flip elem f) + + '\\' -> case s == "" of + True -> return "\\" + False -> do + remainder <- expandEnv $ drop 1 s + return $ escString s ++ remainder + where escString s' = let (cc:_) = s' in + case cc of + 't' -> "\t" + 'n' -> "\n" + '$' -> "$" + _ -> [cc] + + _ -> do + remainder <- expandEnv s + return $ c : remainder diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Main.hs new/xmobar-0.24.2/src/Main.hs --- old/xmobar-0.23.1/src/Main.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Main.hs 2016-08-08 23:40:59.000000000 +0200 @@ -38,6 +38,7 @@ import System.FilePath ((</>)) import System.Posix.Files import Control.Monad (unless, liftM) +import Text.Read (readMaybe) import Signal (setupSignalHandler) @@ -133,6 +134,7 @@ | Template String | OnScr String | IconRoot String + | Position String deriving Show options :: [OptDescr Opts] @@ -166,6 +168,8 @@ "Add to the list of commands to be executed" , Option "x" ["screen"] (ReqArg OnScr "screen") "On which X screen number to start" + , Option "p" ["position"] (ReqArg Position "position") + "Specify position of xmobar. Same syntax as in config file" ] getOpts :: [String] -> IO ([Opts], [String]) @@ -219,6 +223,7 @@ AddCommand s -> case readCom 'C' s of Right x -> doOpts' (conf {commands = commands conf ++ x}) Left e -> putStr (e ++ usage) >> exitWith (ExitFailure 1) + Position s -> readPosition s where readCom c str = case readStr str of [x] -> Right x @@ -226,3 +231,9 @@ "specified with the -" ++ c:" option\n") readStr str = [x | (x,t) <- reads str, ("","") <- lex t] doOpts' opts = doOpts opts oo + readPosition string = + case readMaybe string of + Just x -> doOpts' (conf { position = x }) + Nothing -> do + putStrLn "Can't parse position option, ignoring" + doOpts' conf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/BufferedPipeReader.hs new/xmobar-0.24.2/src/Plugins/BufferedPipeReader.hs --- old/xmobar-0.23.1/src/Plugins/BufferedPipeReader.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/BufferedPipeReader.hs 2016-08-08 23:40:59.000000000 +0200 @@ -20,6 +20,7 @@ import System.IO import System.IO.Unsafe(unsafePerformIO) +import Environment import Plugins import Signal @@ -51,7 +52,8 @@ reader :: (Int, Bool, FilePath) -> TChan (Int, Bool, String) -> IO () reader p@(to, tg, fp) tc = do - openFile fp ReadWriteMode >>= hGetLineSafe >>= \dt -> + fp' <- expandEnv fp + openFile fp' ReadWriteMode >>= hGetLineSafe >>= \dt -> atomically $ writeTChan tc (to, tg, dt) reader p tc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Kbd.hsc new/xmobar-0.24.2/src/Plugins/Kbd.hsc --- old/xmobar-0.23.1/src/Plugins/Kbd.hsc 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/Kbd.hsc 2016-08-08 23:40:59.000000000 +0200 @@ -101,15 +101,15 @@ -- data XkbKeyNameRec = XkbKeyNameRec { - name :: Ptr CChar -- array + name :: Ptr CChar -- array } -- -- the t_ before alias is just because of name collisions -- data XkbKeyAliasRec = XkbKeyAliasRec { - real :: Ptr CChar, -- array - t_alias :: Ptr CChar -- array + real :: Ptr CChar, -- array + t_alias :: Ptr CChar -- array } -- @@ -146,7 +146,7 @@ server :: Ptr CChar, -- XkbServerMapPtr ; dont' care t_map :: Ptr CChar, --XkbClientMapPtr ; dont' care t_indicators :: Ptr CChar, -- XkbIndicatorPtr ; dont' care - names :: Ptr XkbNamesRec, -- array + names :: Ptr XkbNamesRec, -- array t_compat :: Ptr CChar, -- XkbCompatMap ; dont' care geom :: Ptr CChar -- XkbGeometryPtr ; dont' care @@ -264,10 +264,10 @@ xkbFreeKeyboard :: (Ptr XkbDescRec) -> CUInt -> CInt -> IO () foreign import ccall unsafe "X11/XKBlib.h XkbSelectEventDetails" - xkbSelectEventDetails :: Display -> CUInt -> CUInt -> CULong -> CULong -> IO CUInt + xkbSelectEventDetails :: Display -> CUInt -> CUInt -> CULong -> CULong -> IO CUInt foreign import ccall unsafe "X11/XKBlib.h XkbSelectEvents" - xkbSelectEvents :: Display -> CUInt -> CUInt -> CUInt -> IO CUInt + xkbSelectEvents :: Display -> CUInt -> CUInt -> CUInt -> IO CUInt xkbUseCoreKbd :: CUInt @@ -371,11 +371,11 @@ data Kbd = Kbd [(String, String)] - deriving (Read, Show) + deriving (Read, Show) instance Exec Kbd where - alias (Kbd _) = "kbd" - start (Kbd opts) cb = do + alias (Kbd _) = "kbd" + start (Kbd opts) cb = do dpy <- openDisplay "" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/MarqueePipeReader.hs new/xmobar-0.24.2/src/Plugins/MarqueePipeReader.hs --- old/xmobar-0.23.1/src/Plugins/MarqueePipeReader.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/MarqueePipeReader.hs 2016-08-08 23:40:59.000000000 +0200 @@ -15,15 +15,17 @@ module Plugins.MarqueePipeReader where import System.IO (openFile, IOMode(ReadWriteMode), Handle) +import Environment import Plugins (tenthSeconds, Exec(alias, start), hGetLineSafe) import System.Posix.Files (getFileStatus, isNamedPipe) import Control.Concurrent(forkIO, threadDelay) import Control.Concurrent.STM (TChan, atomically, writeTChan, tryReadTChan, newTChan) import Control.Exception import Control.Monad(forever, unless) +import Control.Applicative ((<$>)) type Length = Int -- length of the text to display -type Rate = Int -- delay in tenth seconds +type Rate = Int -- delay in tenth seconds type Separator = String -- if text wraps around, use separator data MarqueePipeReader = MarqueePipeReader String (Length, Rate, Separator) String @@ -32,7 +34,7 @@ instance Exec MarqueePipeReader where alias (MarqueePipeReader _ _ a) = a start (MarqueePipeReader p (len, rate, sep) _) cb = do - let (def, pipe) = split ':' p + (def, pipe) <- split ':' <$> expandEnv p unless (null def) (cb def) checkPipe pipe h <- openFile pipe ReadWriteMode @@ -47,16 +49,16 @@ pipeToChan :: Handle -> TChan String -> IO () pipeToChan h chan = do - line <- hGetLineSafe h + line <- hGetLineSafe h atomically $ writeTChan chan line writer :: String -> Separator -> Length -> Rate -> TChan String -> (String -> IO ()) -> IO () -writer txt sep len rate chan cb = do +writer txt sep len rate chan cb = do cb (take len txt) mbnext <- atomically $ tryReadTChan chan case mbnext of Just new -> writer (toInfTxt new sep) sep len rate chan cb - Nothing -> tenthSeconds rate >> writer (drop 1 txt) sep len rate chan cb + Nothing -> tenthSeconds rate >> writer (drop 1 txt) sep len rate chan cb toInfTxt :: String -> String -> String toInfTxt line sep = concat (repeat $ line ++ " " ++ sep ++ " ") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Monitors/Batt.hs new/xmobar-0.24.2/src/Plugins/Monitors/Batt.hs --- old/xmobar-0.23.1/src/Plugins/Monitors/Batt.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/Monitors/Batt.hs 2016-08-08 23:40:59.000000000 +0200 @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Batt --- Copyright : (c) 2010, 2011, 2012, 2013 Jose A Ortega +-- Copyright : (c) 2010, 2011, 2012, 2013, 2015, 2016 Jose A Ortega -- (c) 2010 Andrea Rossato, Petr Rockai -- License : BSD-style (see LICENSE) -- @@ -21,6 +21,10 @@ import System.IO (IOMode(ReadMode), hGetLine, withFile) import System.Posix.Files (fileExist) import System.Console.GetOpt +import Data.List (sort, sortBy, group) +import Data.Maybe (fromMaybe) +import Data.Ord (comparing) +import Text.Read (readMaybe) data BattOpts = BattOpts { onString :: String @@ -48,8 +52,8 @@ , lowWColor = Nothing , mediumWColor = Nothing , highWColor = Nothing - , lowThreshold = -12 - , highThreshold = -10 + , lowThreshold = 10 + , highThreshold = 12 , onlineFile = "AC/online" , scale = 1e6 , onIconPattern = Nothing @@ -84,7 +88,7 @@ (o, _, []) -> return $ foldr id defaultOpts o (_, _, errs) -> ioError . userError $ concat errs -data Status = Charging | Discharging | Idle +data Status = Charging | Discharging | Full | Idle | Unknown deriving (Read, Eq) data Result = Result Float Float Float Status | NA @@ -101,6 +105,7 @@ , fNow :: String , fVoltage :: String , fCurrent :: String + , fStatus :: String , isCurrent :: Bool } | NoFiles @@ -108,6 +113,7 @@ { full :: !Float , now :: !Float , power :: !Float + , status :: !String } safeFileExist :: String -> String -> IO Bool @@ -132,6 +138,7 @@ , fNow = prefix </> ch ++ "_now" , fCurrent = prefix </> cf , fVoltage = prefix </> "voltage_now" + , fStatus = prefix </> "status" , isCurrent = not ip} haveAc :: FilePath -> IO Bool @@ -140,17 +147,27 @@ where onError = const (return False) :: SomeException -> IO Bool readBattery :: Float -> Files -> IO Battery -readBattery _ NoFiles = return $ Battery 0 0 0 +readBattery _ NoFiles = return $ Battery 0 0 0 "Idle" readBattery sc files = do a <- grab $ fFull files b <- grab $ fNow files d <- grab $ fCurrent files + s <- grabs $ fStatus files let sc' = if isCurrent files then sc / 10 else sc - return $ Battery (3600 * a / sc') -- wattseconds + a' = max a b -- sometimes the reported max charge is lower than + return $ Battery (3600 * a' / sc') -- wattseconds (3600 * b / sc') -- wattseconds (d / sc') -- watts + s -- string: Discharging/Charging/Full 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 + +-- 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)) readBatteries :: BattOpts -> [Files] -> IO Result readBatteries opts bfs = @@ -160,13 +177,13 @@ ft = sum (map full bats) left = if ft > 0 then sum (map now bats) / ft else 0 watts = sign * sum (map power bats) - idle = watts == 0 - time = if idle then 0 else sum $ map time' bats - mwatts = if idle then 1 else sign * watts + time = if watts == 0 then 0 else max 0 (sum $ map time' bats) + mwatts = if watts == 0 then 1 else sign * watts time' b = (if ac then full b - now b else now b) / mwatts - acst | idle = Idle - | ac = Charging - | otherwise = Discharging + 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 runBatt :: [String] -> Monitor String @@ -178,12 +195,13 @@ c <- io $ readBatteries opts =<< mapM batteryFiles bfs suffix <- getConfigValue useSuffix d <- getConfigValue decDigits + nas <- getConfigValue naString case c of Result x w t s -> do l <- fmtPercent x ws <- fmtWatts w opts suffix d si <- getIconPattern opts s x - parseTemplate (l ++ [fmtStatus opts s, fmtTime $ floor t, ws, si]) + parseTemplate (l ++ [fmtStatus opts s nas, fmtTime $ floor t, ws, si]) NA -> getConfigValue naString where fmtPercent :: Float -> Monitor [String] fmtPercent x = do @@ -200,18 +218,22 @@ then minutes else '0' : minutes where hours = show (x `div` 3600) minutes = show ((x `mod` 3600) `div` 60) - fmtStatus opts Idle = idleString opts - fmtStatus opts Charging = onString opts - fmtStatus opts Discharging = offString opts + fmtStatus opts Idle _ = idleString opts + fmtStatus _ Unknown na = na + fmtStatus opts Full _ = idleString opts + fmtStatus opts Charging _ = onString opts + fmtStatus opts Discharging _ = offString opts maybeColor Nothing str = str maybeColor (Just c) str = "<fc=" ++ c ++ ">" ++ str ++ "</fc>" color x o | x >= 0 = maybeColor (posColor o) | -x >= highThreshold o = maybeColor (highWColor o) | -x >= lowThreshold o = maybeColor (mediumWColor o) | otherwise = maybeColor (lowWColor o) - getIconPattern opts status x = do + getIconPattern opts st x = do let x' = minimum [1, x] - case status of + case st of + Unknown -> showIconPattern (offIconPattern opts) x' Idle -> showIconPattern (idleIconPattern opts) x' + Full -> showIconPattern (idleIconPattern opts) x' Charging -> showIconPattern (onIconPattern opts) x' Discharging -> showIconPattern (offIconPattern opts) x' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Monitors/Common.hs new/xmobar-0.24.2/src/Plugins/Monitors/Common.hs --- old/xmobar-0.23.1/src/Plugins/Monitors/Common.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/Monitors/Common.hs 2016-08-08 23:40:59.000000000 +0200 @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Common --- Copyright : (c) 2010, 2011, 2013 Jose Antonio Ortega Ruiz +-- Copyright : (c) 2010, 2011, 2013, 2016 Jose Antonio Ortega Ruiz -- (c) 2007-2010 Andrea Rossato -- License : BSD-style (see LICENSE) -- @@ -83,23 +83,24 @@ data MConfig = MC { normalColor :: IORef (Maybe String) - , low :: IORef Int - , lowColor :: IORef (Maybe String) - , high :: IORef Int - , highColor :: IORef (Maybe String) - , template :: IORef String - , export :: IORef [String] - , ppad :: IORef Int - , decDigits :: IORef Int - , minWidth :: IORef Int - , maxWidth :: IORef Int - , padChars :: IORef String - , padRight :: IORef Bool - , barBack :: IORef String - , barFore :: IORef String - , barWidth :: IORef Int - , useSuffix :: IORef Bool - , naString :: IORef String + , low :: IORef Int + , lowColor :: IORef (Maybe String) + , high :: IORef Int + , highColor :: IORef (Maybe String) + , template :: IORef String + , export :: IORef [String] + , ppad :: IORef Int + , decDigits :: IORef Int + , minWidth :: IORef Int + , maxWidth :: IORef Int + , padChars :: IORef String + , padRight :: IORef Bool + , barBack :: IORef String + , barFore :: IORef String + , barWidth :: IORef Int + , useSuffix :: IORef Bool + , naString :: IORef String + , maxTotalWidth :: IORef Int } -- | from 'http:\/\/www.haskell.org\/hawiki\/MonadState' @@ -144,7 +145,8 @@ bw <- newIORef 10 up <- newIORef False na <- newIORef "N/A" - return $ MC nc l lc h hc t e p d mn mx pc pr bb bf bw up na + mt <- newIORef 0 + return $ MC nc l lc h hc t e p d mn mx pc pr bb bf bw up na mt data Opts = HighColor String | NormalColor String @@ -164,6 +166,7 @@ | BarWidth String | UseSuffix String | NAString String + | MaxTotalWidth String options :: [OptDescr Opts] options = @@ -186,6 +189,7 @@ , Option "f" ["bfore"] (ReqArg BarFore "bar foreground") "Characters used to draw bar foregrounds" , Option "W" ["bwidth"] (ReqArg BarWidth "bar width") "Bar width" , Option "x" ["nastring"] (ReqArg NAString "N/A string") "String used when the monitor is not available" + , Option "T" ["maxtwidth"] (ReqArg MaxTotalWidth "Maximum total width") "Maximum total width" ] doArgs :: [String] -> ([String] -> Monitor String) -> ([String] -> Monitor Bool) -> Monitor String @@ -223,7 +227,8 @@ BarFore s -> setConfigValue s barFore BarWidth w -> setConfigValue (nz w) barWidth UseSuffix u -> setConfigValue (bool u) useSuffix - NAString s -> setConfigValue s naString) >> next + NAString s -> setConfigValue s naString + MaxTotalWidth w -> setConfigValue (nz w) maxTotalWidth) >> next runM :: [String] -> IO MConfig -> ([String] -> Monitor String) -> Int -> (String -> IO ()) -> IO () @@ -324,13 +329,16 @@ -- | Takes a list of strings that represent the values of the exported -- keys. The strings are joined with the exported keys to form a map -- to be combined with 'combine' to the parsed template. Returns the --- final output of the monitor. +-- final output of the monitor, trimmed to MaxTotalWidth if that +-- configuration value is positive. parseTemplate :: [String] -> Monitor String parseTemplate l = do t <- getConfigValue template e <- getConfigValue export + w <- getConfigValue maxTotalWidth let m = Map.fromList . zip e $ l - parseTemplate' t m + s <- parseTemplate' t m + return $ if w > 0 && length s > w then take w s else s -- | Parses the template given to it with a map of export values and combines -- them @@ -488,7 +496,7 @@ where t = 9600 + (round val `div` 12) showLogBar :: Float -> Float -> Monitor String -showLogBar f v = +showLogBar f v = let intConfig c = fromIntegral `fmap` getConfigValue c in do h <- intConfig high diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Monitors/MPD.hs new/xmobar-0.24.2/src/Plugins/Monitors/MPD.hs --- old/xmobar-0.23.1/src/Plugins/Monitors/MPD.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/Monitors/MPD.hs 2016-08-08 23:40:59.000000000 +0200 @@ -26,7 +26,7 @@ [ "bar", "vbar", "ipat", "state", "statei", "volume", "length" , "lapsed", "remaining", "plength", "ppos", "flags", "file" , "name", "artist", "composer", "performer" - , "album", "title", "track", "genre" + , "album", "title", "track", "genre", "date" ] data MOpts = MOpts @@ -63,7 +63,7 @@ mpdWait :: IO () mpdWait = do - status <- M.withMPD $ M.idle [M.PlayerS, M.MixerS] + status <- M.withMPD $ M.idle [M.PlayerS, M.MixerS, M.OptionsS] case status of Left _ -> threadDelay 10000000 _ -> return () @@ -126,7 +126,7 @@ parseSong (Right (Just s)) = let str sel = maybe "" (intercalate ", " . map M.toString) (M.sgGetTag sel s) sels = [ M.Name, M.Artist, M.Composer, M.Performer - , M.Album, M.Title, M.Track, M.Genre ] + , M.Album, M.Title, M.Track, M.Genre, M.Date ] fields = M.toString (M.sgFilePath s) : map str sels in mapM showWithPadding fields diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Monitors/Mpris.hs new/xmobar-0.24.2/src/Plugins/Monitors/Mpris.hs --- old/xmobar-0.23.1/src/Plugins/Monitors/Mpris.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/Monitors/Mpris.hs 2016-08-08 23:40:59.000000000 +0200 @@ -84,7 +84,7 @@ runMPRIS :: (MprisVersion a) => a -> String -> [String] -> Monitor String runMPRIS version playerName _ = do metadata <- io $ getMetadata version dbusClient playerName - parseTemplate $ makeList version metadata + mapM showWithPadding (makeList version metadata) >>= parseTemplate runMPRIS1 :: String -> [String] -> Monitor String runMPRIS1 = runMPRIS MprisVersion1 @@ -99,12 +99,15 @@ unpackMetadata :: [Variant] -> [(String, Variant)] unpackMetadata [] = [] -unpackMetadata xs = (map (fromVar *** fromVar) . unpack . head) xs where - unpack v = case variantType v of - TypeDictionary _ _ -> dictionaryItems $ fromVar v - TypeVariant -> unpack $ fromVar v - TypeStructure _ -> unpack $ head $ structureItems $ fromVar v - _ -> [] +unpackMetadata xs = + (map (fromVar *** fromVar) . unpack . head) xs where + unpack v = case variantType v of + TypeDictionary _ _ -> dictionaryItems $ fromVar v + TypeVariant -> unpack $ fromVar v + TypeStructure _ -> + let x = structureItems (fromVar v) in + if x == [] then [] else unpack (head x) + _ -> [] getMetadata :: (MprisVersion a) => a -> DC.Client -> String -> IO [(String, Variant)] getMetadata version client player = do @@ -136,5 +139,7 @@ case str of "mpris:length" -> formatTime (num `div` 1000000) _ -> (show::Int64 -> String) num - TypeArray TypeString -> fromVar $ head $ arrayItems $ fromVar v + TypeArray TypeString -> + let x = arrayItems (fromVar v) in + if x == [] then "" else fromVar (head x) _ -> "" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Monitors/UVMeter.hs new/xmobar-0.24.2/src/Plugins/Monitors/UVMeter.hs --- old/xmobar-0.23.1/src/Plugins/Monitors/UVMeter.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/xmobar-0.24.2/src/Plugins/Monitors/UVMeter.hs 2016-08-08 23:40:59.000000000 +0200 @@ -0,0 +1,150 @@ +{-# LANGUAGE OverloadedStrings #-} +----------------------------------------------------------------------------- +-- | +-- Module : Plugins.Monitors.UVMeter +-- Copyright : (c) Róman Joost +-- License : BSD-style (see LICENSE) +-- +-- Maintainer : Róman Joost +-- Stability : unstable +-- Portability : unportable +-- +-- An australian uv monitor for Xmobar +-- +----------------------------------------------------------------------------- + +module Plugins.Monitors.UVMeter where + +import Plugins.Monitors.Common + +import qualified Control.Exception as CE +import Control.Applicative hiding ((<|>),many) +import Network.HTTP +import Text.Read (readMaybe) +import Text.Parsec +import Text.Parsec.String + + +uvConfig :: IO MConfig +uvConfig = mkMConfig + "<station>" -- template + ["station" -- available replacements + ] + +data UvInfo = UV { index :: String } + deriving (Show) + +uvURL :: String +uvURL = "http://www.arpansa.gov.au/uvindex/realtime/xml/uvvalues.xml" + +getData :: IO String +getData = do + let request = getRequest uvURL + CE.catch (simpleHTTP request >>= getResponseBody) errHandler + where errHandler :: CE.IOException -> IO String + errHandler _ = return "<Could not retrieve data>" + +textToXMLDocument :: String -> Either ParseError [XML] +textToXMLDocument = parse document "" + +formatUVRating :: Maybe Float -> Monitor String +formatUVRating Nothing = getConfigValue naString +formatUVRating (Just x) = do + uv <- showWithColors show x + parseTemplate [uv] + +getUVRating :: String -> [XML] -> Maybe Float +getUVRating locID (Element "stations" _ y:_) = getUVRating locID y +getUVRating locID (Element "location" [Attribute attr] ys:xs) + | locID == snd attr = getUVRating locID ys + | otherwise = getUVRating locID xs +getUVRating _ (Element "index" [] [Body rate]:_) = readMaybe rate +getUVRating locID (_:xs) = getUVRating locID xs +getUVRating _ [] = Nothing + + +runUVMeter :: [String] -> Monitor String +runUVMeter [] = return "N.A." +runUVMeter (s:_) = do + resp <- io getData + case textToXMLDocument resp of + Right doc -> formatUVRating (getUVRating s doc) + Left _ -> getConfigValue naString + +-- | XML Parsing code comes here. +-- This is a very simple XML parser to just deal with the uvvalues.xml +-- provided by ARPANSA. If you work on a new plugin which needs an XML +-- parser perhaps consider using a real XML parser and refactor this +-- plug-in to us it as well. +-- +-- Note: This parser can not deal with short tags. +-- +-- Kudos to: Charlie Harvey for his article about writing an XML Parser +-- with Parsec. +-- + +type AttrName = String +type AttrValue = String + +data Attribute = Attribute (AttrName, AttrValue) + deriving (Show) + +data XML = Element String [Attribute] [XML] + | Decl String + | Body String + deriving (Show) + +-- | parse the document +-- +document :: Parser [XML] +document = do + spaces + y <- try xmlDecl <|> tag + spaces + x <- many tag + spaces + return (y : x) + +-- | parse any tags +-- +tag :: Parser XML +tag = do + char '<' + spaces + name <- many (letter <|> digit) + spaces + attr <- many attribute + spaces + string ">" + eBody <- many elementBody + endTag name + spaces + return (Element name attr eBody) + +xmlDecl :: Parser XML +xmlDecl = do + string "<?xml" + decl <- many (noneOf "?>") + string "?>" + return (Decl decl) + +elementBody :: Parser XML +elementBody = spaces *> try tag <|> text + +endTag :: String -> Parser String +endTag str = string "</" *> string str <* char '>' + +text :: Parser XML +text = Body <$> many1 (noneOf "><") + +attribute :: Parser Attribute +attribute = do + name <- many (noneOf "= />") + spaces + char '=' + spaces + char '"' + value <- many (noneOf "\"") + char '"' + spaces + return (Attribute (name, value)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Monitors/Volume.hs new/xmobar-0.24.2/src/Plugins/Monitors/Volume.hs --- old/xmobar-0.23.1/src/Plugins/Monitors/Volume.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/Monitors/Volume.hs 2016-08-08 23:40:59.000000000 +0200 @@ -15,7 +15,7 @@ module Plugins.Monitors.Volume (runVolume, volumeConfig) where import Control.Applicative ((<$>)) -import Control.Monad ( join, liftM2, liftM3, mplus ) +import Control.Monad ( liftM2, liftM3, mplus ) import Data.Traversable (sequenceA) import Plugins.Monitors.Common import Sound.ALSA.Mixer @@ -144,12 +144,14 @@ (const $ return (Nothing, Nothing, Nothing, Nothing, Nothing)) volumeControl :: Maybe Control -> Maybe Volume - volumeControl c = join $ - (playback . volume <$> c) `mplus` (common . volume <$> c) + volumeControl c = (playback . volume =<< c) + `mplus` (capture . volume =<< c) + `mplus` (common . volume =<< c) switchControl :: Maybe Control -> Maybe Switch - switchControl c = join $ - (playback . switch <$> c) `mplus` (common . switch <$> c) + switchControl c = (playback . switch =<< c) + `mplus` (capture . switch =<< c) + `mplus` (common . switch =<< c) liftMaybe :: Maybe (IO (a,b)) -> IO (Maybe a, Maybe b) liftMaybe = fmap (liftM2 (,) (fmap fst) (fmap snd)) . sequenceA diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Monitors/Weather.hs new/xmobar-0.24.2/src/Plugins/Monitors/Weather.hs --- old/xmobar-0.23.1/src/Plugins/Monitors/Weather.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/Monitors/Weather.hs 2016-08-08 23:40:59.000000000 +0200 @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Weather @@ -18,7 +19,14 @@ import qualified Control.Exception as CE +#ifdef HTTP_CONDUIT +import Network.HTTP.Conduit +import Network.HTTP.Types.Status +import Network.HTTP.Types.Method +import qualified Data.ByteString.Lazy.Char8 as B +#else import Network.HTTP +#endif import Text.ParserCombinators.Parsec @@ -35,6 +43,8 @@ , "windAzimuth" , "windMph" , "windKnots" + , "windKmh" + , "windMs" , "visibility" , "skyCondition" , "tempC" @@ -45,6 +55,16 @@ , "pressure" ] +data WindInfo = + WindInfo { + windCardinal :: String -- cardinal direction + , windAzimuth :: String -- azimuth direction + , windMph :: String -- speed (MPH) + , windKnots :: String -- speed (knot) + , windKmh :: String -- speed (km/h) + , windMs :: String -- speed (m/s) + } deriving (Show) + data WeatherInfo = WI { stationPlace :: String , stationState :: String @@ -52,10 +72,7 @@ , month :: String , day :: String , hour :: String - , windCardinal :: String - , windAzimuth :: String - , windMph :: String - , windKnots :: String + , windInfo :: WindInfo , visibility :: String , skyCondition :: String , tempC :: Int @@ -77,34 +94,26 @@ char ' ' return (y, m, d ,h:hh:":"++mi:mimi) --- Occasionally there is no wind and a METAR report gives simply, "Wind: Calm:0" -pWind0 :: - ( - String -- cardinal direction - , String -- azimuth direction - , String -- speed (MPH) - , String -- speed (knot) - ) -pWind0 = - ("μ", "μ", "0", "0") - -pWind :: - Parser ( - String -- cardinal direction - , String -- azimuth direction - , String -- speed (MPH) - , String -- speed (knot) - ) +noWind :: WindInfo +noWind = WindInfo "μ" "μ" "0" "0" "0" "0" + +pWind :: Parser WindInfo pWind = let tospace = manyTill anyChar (char ' ') + toKmh knots = knots $* 1.852 + toMs knots = knots $* 0.514 + ($*) :: String -> Double -> String + op1 $* op2 = show (round ((read op1::Double) * op2)::Integer) + + -- Occasionally there is no wind and a METAR report gives simply, "Wind: Calm:0" wind0 = do manyTill skipRestOfLine (string "Wind: Calm:0") - return pWind0 + return noWind windVar = do manyTill skipRestOfLine (string "Wind: Variable at ") mph <- tospace string "MPH (" knot <- tospace manyTill anyChar newline - return ("μ", "μ", mph, knot) + return $ WindInfo "μ" "μ" mph knot (toKmh knot) (toMs knot) wind = do manyTill skipRestOfLine (string "Wind: from the ") cardinal <- tospace char '(' @@ -114,8 +123,8 @@ string "MPH (" knot <- tospace manyTill anyChar newline - return (cardinal, azimuth, mph, knot) - in try wind0 <|> try windVar <|> wind + return $ WindInfo cardinal azimuth mph knot (toKmh knot) (toMs knot) + in try wind0 <|> try windVar <|> try wind <|> return noWind pTemp :: Parser (Int, Int) pTemp = do let num = digit <|> char '-' <|> char '.' @@ -159,7 +168,7 @@ ) skipRestOfLine >> getAllBut "/" (y,m,d,h) <- pTime - (wc, wa, wm, wk) <- pWind + w <- pWind v <- getAfterString "Visibility: " sk <- getAfterString "Sky conditions: " skipTillString "Temperature: " @@ -171,26 +180,38 @@ skipTillString "Pressure (altimeter): " p <- pPressure manyTill skipRestOfLine eof - return [WI st ss y m d h wc wa wm wk v sk tC tF dC dF rh p] + return [WI st ss y m d h w v sk tC tF dC dF rh p] defUrl :: String -defUrl = "http://weather.noaa.gov/pub/data/observations/metar/decoded/" +-- "http://weather.noaa.gov/pub/data/observations/metar/decoded/" +defUrl = "http://tgftp.nws.noaa.gov/data/observations/metar/decoded/" stationUrl :: String -> String stationUrl station = defUrl ++ station ++ ".TXT" getData :: String -> IO String +#ifdef HTTP_CONDUIT +getData station = CE.catch (do + manager <- newManager tlsManagerSettings + request <- parseUrl $ stationUrl station + res <- httpLbs request manager + return $ B.unpack $ responseBody res + ) errHandler + where errHandler :: CE.SomeException -> IO String + errHandler _ = return "<Could not retrieve data>" +#else getData station = do let request = getRequest (stationUrl station) CE.catch (simpleHTTP request >>= getResponseBody) errHandler where errHandler :: CE.IOException -> IO String errHandler _ = return "<Could not retrieve data>" +#endif formatWeather :: [WeatherInfo] -> Monitor String -formatWeather [WI st ss y m d h wc wa wm wk v sk tC tF dC dF r p] = +formatWeather [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, v, sk, cel, far, show dC, show dF, show r , show p ] + 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 runWeather :: [String] -> Monitor String @@ -200,6 +221,21 @@ formatWeather i weatherReady :: [String] -> Monitor Bool +#ifdef HTTP_CONDUIT +weatherReady str = do + initRequest <- parseUrl $ stationUrl $ head str + let request = initRequest{method = methodHead} + io $ CE.catch ( do + manager <- newManager tlsManagerSettings + res <- httpLbs request manager + return $ checkResult $responseStatus res ) errHandler + where errHandler :: CE.SomeException -> IO Bool + errHandler _ = return False + checkResult status + | statusIsServerError status = False + | statusIsClientError status = False + | otherwise = True +#else weatherReady str = do let station = head str request = headRequest (stationUrl station) @@ -216,3 +252,4 @@ (4, _, _) -> return False (5, _, _) -> return False (_, _, _) -> return True +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/Monitors.hs new/xmobar-0.24.2/src/Plugins/Monitors.hs --- old/xmobar-0.23.1/src/Plugins/Monitors.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/Monitors.hs 2016-08-08 23:40:59.000000000 +0200 @@ -36,6 +36,9 @@ import Plugins.Monitors.Top import Plugins.Monitors.Uptime import Plugins.Monitors.CatInt +#ifdef UVMETER +import Plugins.Monitors.UVMeter +#endif #ifdef IWLIB import Plugins.Monitors.Wireless #endif @@ -71,6 +74,9 @@ | TopMem Args Rate | Uptime Args Rate | CatInt Int FilePath Args Rate +#ifdef UVMETER + | UVMeter Station Args Rate +#endif #ifdef IWLIB | Wireless Interface Args Rate #endif @@ -119,6 +125,9 @@ alias (DiskIO {}) = "diskio" alias (Uptime _ _) = "uptime" alias (CatInt n _ _ _) = "cat" ++ show n +#ifdef UVMETER + alias (UVMeter s _ _) = "uv " ++ s +#endif #ifdef IWLIB alias (Wireless i _ _) = i ++ "wi" #endif @@ -155,6 +164,9 @@ start (DiskIO s a r) = startDiskIO s a r start (Uptime a r) = runM a uptimeConfig runUptime r start (CatInt _ s a r) = runM a catIntConfig (runCatInt s) r +#ifdef UVMETER + start (UVMeter s a r) = runM (a ++ [s]) uvConfig runUVMeter r +#endif #ifdef IWLIB start (Wireless i a r) = runM a wirelessConfig (runWireless i) r #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Plugins/PipeReader.hs new/xmobar-0.24.2/src/Plugins/PipeReader.hs --- old/xmobar-0.23.1/src/Plugins/PipeReader.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Plugins/PipeReader.hs 2016-08-08 23:40:59.000000000 +0200 @@ -16,10 +16,12 @@ import System.IO import Plugins +import Environment import System.Posix.Files import Control.Concurrent(threadDelay) import Control.Exception import Control.Monad(forever, unless) +import Control.Applicative ((<$>)) data PipeReader = PipeReader String String deriving (Read, Show) @@ -27,7 +29,7 @@ instance Exec PipeReader where alias (PipeReader _ a) = a start (PipeReader p _) cb = do - let (def, pipe) = split ':' p + (def, pipe) <- split ':' <$> expandEnv p unless (null def) (cb def) checkPipe pipe h <- openFile pipe ReadWriteMode @@ -42,4 +44,4 @@ handle (\(SomeException _) -> waitForPipe) $ do status <- getFileStatus file unless (isNamedPipe status) waitForPipe - where waitForPipe = threadDelay 1000 >> checkPipe file + where waitForPipe = threadDelay 1000000 >> checkPipe file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/XUtil.hsc new/xmobar-0.24.2/src/XUtil.hsc --- old/xmobar-0.23.1/src/XUtil.hsc 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/XUtil.hsc 2016-08-08 23:40:59.000000000 +0200 @@ -33,6 +33,7 @@ import Control.Monad (when) import Control.Monad.Trans import Control.Exception (SomeException, handle) +import Data.List import Foreign import Graphics.X11.Xlib hiding (textExtents, textWidth) import qualified Graphics.X11.Xlib as Xlib (textExtents, textWidth) @@ -49,7 +50,6 @@ # endif #endif #if defined XFT -import Data.List import MinXft import Graphics.X11.Xrender #endif @@ -81,12 +81,18 @@ -- to the Xft backend Example: 'xft:Sans-10' initFont :: Display ->String -> IO XFont initFont d s = -#ifdef XFT let xftPrefix = "xft:" in if xftPrefix `isPrefixOf` s then +#ifdef XFT fmap Xft $ initXftFont d s - else +#else + do + hPutStrLn stderr $ "Warning: Xmobar must be built with " + ++ "the with_xft flag to support font '" ++ s + ++ ".' Falling back on default." + initFont d miscFixedFont #endif + else #if defined UTF8 || __GLASGOW_HASKELL__ >= 612 fmap Utf8 $ initUtf8Font d s #else @@ -184,7 +190,7 @@ when (al == 255) $ do (a,d) <- textExtents fs s gi <- xftTxtExtents' dpy fonts s - drawXftRect draw bc' x (y - a + 1) (xglyphinfo_xOff gi) (a + d + 1) + drawXftRect draw bc' x (y - a) (1 + xglyphinfo_xOff gi) (a + d + 2) drawXftString' draw fc' fonts (toInteger x) (toInteger y) s #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/src/Xmobar.hs new/xmobar-0.24.2/src/Xmobar.hs --- old/xmobar-0.23.1/src/Xmobar.hs 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/src/Xmobar.hs 2016-08-08 23:40:59.000000000 +0200 @@ -347,7 +347,7 @@ (fc,bc) = case break (==',') c of (f,',':b) -> (f, b ) (f, _) -> (f, bgColor conf) - valign <- verticalOffset ht s fontst conf + valign <- verticalOffset ht s (head fontlist) conf case s of (Text t) -> io $ printString d dr fontst gc fc bc offset valign t alph (Icon p) -> io $ maybe (return ()) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/xmobar-0.23.1/xmobar.cabal new/xmobar-0.24.2/xmobar.cabal --- old/xmobar-0.23.1/xmobar.cabal 2015-04-14 19:08:19.000000000 +0200 +++ new/xmobar-0.24.2/xmobar.cabal 2016-08-08 23:40:59.000000000 +0200 @@ -1,5 +1,5 @@ name: xmobar -version: 0.23.1 +version: 0.24.2 homepage: http://xmobar.org synopsis: A Minimalistic Text Based Status Bar description: Xmobar is a minimalistic text based status bar. @@ -74,12 +74,21 @@ description: Use threaded runtime. default: False +flag with_uvmeter + description: UVMeter only useful to australians. + default: False + +flag with_conduit + description: Use http-conduits for getting weather data + default: False + executable xmobar hs-source-dirs: src main-is: Main.hs other-modules: Xmobar, Actions, Bitmap, Config, Parsers, Commands, Localize, XUtil, XPMFile, StatFS, Runnable, ColorCache, Window, Signal, + Environment, Plugins, Plugins.BufferedPipeReader, Plugins.CommandReader, Plugins.Date, Plugins.EWMH, Plugins.PipeReader, Plugins.MarqueePipeReader, @@ -93,9 +102,9 @@ Plugins.Monitors.Swap, Plugins.Monitors.Thermal, Plugins.Monitors.ThermalZone, Plugins.Monitors.Top, Plugins.Monitors.Uptime, Plugins.Monitors.Weather, - Plugins.Monitors.Bright, Plugins.Monitors.CatInt + Plugins.Monitors.Bright, Plugins.Monitors.CatInt, + Plugins.Monitors.UVMeter - ghc-prof-options: -prof -auto-all ghc-options: -funbox-strict-fields -Wall -fno-warn-unused-do-bind extra-libraries: Xrandr Xrender @@ -117,6 +126,11 @@ HTTP >= 4000.2.4, stm >= 2.3 && < 2.5 + if flag(with_conduit) + -- use http-conduit instead of simple-http + build-depends: http-conduit, http-types + cpp-options: -DHTTP_CONDUIT + if flag(with_threaded) -- -threaded is a workaround for 100% CPU busy loop -- (http://hackage.haskell.org/trac/ghc/ticket/4934). @@ -152,7 +166,7 @@ cpp-options: -DLIBMPD if flag(with_alsa) || flag(all_extensions) - build-depends: alsa-mixer == 0.2.* + build-depends: alsa-mixer > 0.2.0.2 build-depends: alsa-core == 0.5.* other-modules: Plugins.Monitors.Volume cpp-options: -DALSA @@ -176,3 +190,6 @@ extra-libraries: Xpm other-modules: XPMFile cpp-options: -DXPM + + if flag(with_uvmeter) + cpp-options: -DUVMETER