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

System.Taffybar.Weather

Contents

Description

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

 http://lwf.ncdc.noaa.gov/oa/climate/stationlocator.html

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.

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 Celcius
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

Types

data WeatherConfig

Constructors

WeatherConfig 

Fields

weatherStation :: String

The weather station to poll. No default

weatherTemplate :: String

Template string, as described above. Default: $tempF$ F

weatherFormatter :: WeatherFormatter

Default: substitute in all interpolated variables (above)

Constructor

weatherNew

Arguments

:: WeatherConfig

Configuration to render

-> Double

Polling period in _minutes_

-> IO Widget 

Create a periodically-updating weather widget that polls NOAA.

defaultWeatherConfig :: String -> WeatherConfig

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