Skip to content

WeatherProps

A native component within hitokage that displays current weather information.

It polls Open Meteo every minute.

Only one location is supported at the moment. The very first instance of Weather being attached to a monitor must contain a latitude and longitude. All other Weather will assume the same location.

See ComponentProps

Example

monitor = hitokage.monitor.get_primary()

---@type WeatherProps
weather_props = { latitude = 38.95773795883854, longitude = -95.25382422045898, format = "{{temp_fahrenheit}} °F" }

monitor:attach({
  children = {
    Weather = weather_props,
  },
})

The mounted API is documented here: Weather

Attributes:

attr class

class: (string|table<number, string>)?

Type: (string|table<number, string>?

Optional css class names. Either space-delimited classes, or an array of class names. Built-in hitokage components will always contain their type as a class name.

Example

class = "red blue green"
or
class = {"red", "blue", "green"}

View gtk4 documentation

attr format

format: string|ReactiveString|fun(forecast: WeatherForecast):string

Type: string|ReactiveString|fun(forecast: WeatherForecast):string

A handlebars template string or function accepts WeatherForecast and returns a handlebars template string

attr halign

halign: ('Baseline'|'Center'|'End'|'Fill'|'Start'...(+1))?

Type: ('Baseline'|'Center'|'End'|'Fill'|'Start'...(+1))?

Sets the horizontal alignment of widget. Defaults to 'Fill'

View gtk4 documentation

attr height_request

height_request: integer?

Type: integer?

Override for height request of the widget. If this is -1, the natural request will be used.

View gtk4 documentation

attr hexpand

hexpand: boolean?

Type: boolean?

Whether to expand horizontally. Defaults to false

View gtk4 documentation

attr icons

icons: table<string, string>?

Type: table<string, string>?

A table of "names" mapped to "icons". Below is the default table, as well as what each name corresponds to in terms of Open Meteo's weather codes (which are themselves based on WMO weather codes).

More details at: https://open-meteo.com/en/docs

These icons are based on the assumption you are using a nerd-font.

Name Icon Weather Codes
day "\u{E30D}" 0
day_cloudy "\u{E302}" 1, 2, 3
day_foggy "\u{E303}" 45, 48
day_drizzle "\u{E30B}" 51, 53, 55
day_rain "\u{E305}" 61, 63, 65
day_showers "\u{E309}" 80, 81, 82
day_freezing_rain "\u{E306}" 66, 67
day_snow "\u{E30A}" 85, 86
day_thunderstorm "\u{E30F}" 95
day_hail "\u{E365}" 96, 99
night "\u{E32B}" 0
night_cloudy "\u{E37E}" 1, 2, 3
night_foggy "\u{E346}" 45, 48
night_drizzle "\u{E328}" 51, 53, 55
night_rain "\u{E325}" 61, 63, 65
night_showers "\u{E326}" 80, 81, 82
night_freezing_rain "\u{E323}" 66, 67
night_snow "\u{E327}" 85, 86
night_thunderstorm "\u{E32A}" 95
night_hail "\u{E367}" 96, 99
unknown "\u{F128}" *

Example

Weather = {
  icons = {
    night = "\u{E32B}"
  }
}

attr id

id: string?

Type: string?

A unique identifier.

This is not enforced or checked by hitokage, it is simply used in utility methods such as Bar:get_child_by_id or Box:get_child_by_id.

attr latitude

latitude: number?

Type: number?

The latitude of the location to receive weather forecasts for. It is only necessary on the very first declaration of a weather component. Only one location is supported at the moment.

attr longitude

longitude: number?

Type: number?

The longitude of the location to receive weather forecasts for. It is only necessary on the very first declaration of a weather component. Only one location is supported at the moment.

attr valign

valign: ('Baseline'|'Center'|'End'|'Fill'|'Start'...(+1))?

Type: ('Baseline'|'Center'|'End'|'Fill'|'Start'...(+1))?

Sets the vertical alignment of widget. Defaults to 'Fill'.

View gtk4 documentation

attr vexpand

vexpand: boolean?

Type: boolean?

Whether to expand vertically. Defaults to false

View gtk4 documentation

attr width_request

width_request: integer?

Type: integer?

Override for width request of the widget. If this is -1, the natural request will be used.

View gtk4 documentation