taffybar-3.1.1: A desktop bar similar to xmobar, but with more GUI

Safe HaskellNone
LanguageHaskell2010

System.Taffybar.Widget.Weather

Description

This module defines a simple textual weather widget that polls NOAA for weather data. To find your weather station, you can use

http://www.nws.noaa.gov/tg/siteloc.php

For example, Madison, WI is KMSN.

NOAA provides several pieces of information in each request; you can control which pieces end up in your weather widget by providing a _template_ that is filled in with the current information. The template is just a String with variables between dollar signs. The variables will be substituted with real data by the widget. Example:

let wcfg = (defaultWeatherConfig "KMSN") { weatherTemplate = "$tempC$ C @ $humidity$" }
    weatherWidget = weatherNew wcfg 10

This example makes a new weather widget that checks the weather at KMSN (Madison, WI) every 10 minutes, and displays the results in Celcius.

Available variables:

stationPlace
The name of the weather station
stationState
The state that the weather station is in
year
The year the report was generated
month
The month the report was generated
day
The day the report was generated
hour
The hour the report was generated
wind
The direction and strength of the wind
visibility
Description of current visibility conditions
skyCondition
?
tempC
The temperature in Celsius
tempF
The temperature in Farenheit
dewPoint
The current dew point
humidity
The current relative humidity
pressure
The current pressure

As an example, a template like

"$tempF$ °F"

would yield a widget displaying the temperature in Farenheit with a small label after it.

Implementation Note: the weather data parsing code is taken from xmobar. This version of the code makes direct HTTP requests instead of invoking a separate cURL process.

Synopsis

Documentation

data WeatherConfig Source #

The configuration for the weather widget. You can provide a custom format string through weatherTemplate as described above, or you can provide a custom function to turn a WeatherInfo into a String via the weatherFormatter field.

Constructors

WeatherConfig 

Fields

data WeatherFormatter Source #

A wrapper to allow users to specify a custom weather formatter. The default interpolates variables into a string as described above. Custom formatters can do basically anything.

Constructors

WeatherFormatter (WeatherInfo -> String)

Specify a custom formatter for WeatherInfo

weatherNew Source #

Arguments

:: MonadIO m 
=> WeatherConfig

Configuration to render

-> Double

Polling period in _minutes_

-> m Widget 

Create a periodically-updating weather widget that polls NOAA.

weatherCustomNew Source #

Arguments

:: MonadIO m 
=> IO (Either String WeatherInfo)

Weather querying action

-> String

Weather template

-> String

Weather template

-> WeatherFormatter

Weather formatter

-> Double

Polling period in _minutes_

-> m Widget 

Create a periodically-updating weather widget using custom weather getter

defaultWeatherConfig :: String -> WeatherConfig Source #

A sensible default configuration for the weather widget that just renders the temperature.