Skip to content

Weather

A userdata which corresponds to the mounted version of 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.

This userdata can be retrieved using:

Example

monitor = hitokage.monitor.get_primary()

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

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

weather1 = bar:get_child_by_id("battery1")

Attributes:

Methods:

attr type

type: 'Weather'

Type: 'Weather'

method get_class

function get_class() -> table<number, string>

Get the css classes as an array of strings.

Returns:

method get_format

function get_format() -> string

Get the format string

Returns:

method get_format_reactive

function get_format_reactive() -> ReactiveString

Get the reactive format string

Returns:

method get_halign

function get_halign() -> 'Baseline'|'Center'|'End'|'Fill'|'Start'...(+1)

Gets the horizontal alignment of widget.

View gtk4 documentation

return #1:
    | 'Fill'
    | 'Start'
    | 'End'
    | 'Center'
    | 'Baseline'

Returns:

method get_height

function get_height() -> integer

Returns the content height of the widget.

To learn more about widget sizes, see the coordinate system overview.

View gtk4 documentation

Returns:

method get_height_request

function get_height_request() -> integer

Gets the height request that was explicitly set for the widget using set_height_request or set_size_request.

A value of -1 stored in height indicates that it has not been set explicitly and the natural requisition of the widget will be used instead. To get the height a widget will actually request, call measure_height instead of this function.

See also: get_width_request, get_size_request.

View gtk4 documentation

Returns:

method get_hexpand

function get_hexpand() -> boolean

Gets whether the widget would like any available extra horizontal space.

View gtk4 documentation

Returns:

method get_size_request

function get_size_request() -> [integer, integer]

Gets the size request that was explicitly set for the widget using set_size_request.

A value of -1 stored in width or height indicates that that dimension has not been set explicitly and the natural requisition of the widget will be used instead. To get the size a widget will actually request, call measure instead of this function.

See also: get_width_request, get_height_request.

View gtk4 documentation

Returns:

  • [integer, integer]

method get_type

function get_type() -> 'Weather'

Get the type of widget

return #1:
    | 'Weather'

Returns:

method get_valign

function get_valign() -> 'Baseline'|'Center'|'End'|'Fill'|'Start'...(+1)

Gets the vertical alignment of widget.

View gtk4 documentation

return #1:
    | 'Fill'
    | 'Start'
    | 'End'
    | 'Center'
    | 'Baseline'

Returns:

method get_vexpand

function get_vexpand() -> boolean

Gets whether the widget would like any available extra vertical space.

View gtk4 documentation

Returns:

method get_width

function get_width() -> integer

Returns the content width of the widget.

To learn more about widget sizes, see the coordinate system overview.

View gtk4 documentation

Returns:

method get_width_request

function get_width_request() -> integer

Gets the width request that was explicitly set for the widget using set_width_request or set_size_request.

A value of -1 stored in width indicates that it has not been set explicitly and the natural requisition of the widget will be used instead. To get the width a widget will actually request, call measure_width instead of this function.

See also: get_height_request, get_size_request.

View gtk4 documentation

Returns:

method set_class

function set_class(...string) -> nil

Set the css classes either as a space delimited string or array of strings.

Returns:

method set_format

function set_format(string: string) -> nil

Set the format string

Parameters:

Returns:

method set_halign

function set_halign(halign: 'Baseline'|'Center'|'End'|'Fill'|'Start'...(+1)) -> nil

Sets the horizontal alignment of widget.

View gtk4 documentation

halign:
    | 'Fill'
    | 'Start'
    | 'End'
    | 'Center'
    | 'Baseline'

Parameters:

Returns:

method set_height_request

function set_height_request(height: integer?) -> nil

Sets the minimum height of a widget.

That is, the widget’s size request will be at least height. You can use this function to force a widget to be taller than it normally would be.

If the height request in a given direction is -1 (unset), then the “natural” height request of the widget will be used instead.

See also: set_width_request, set_size_request.

View gtk4 documentation

Parameters:

Returns:

method set_hexpand

function set_hexpand(hexpand: boolean) -> nil

Sets whether the widget would like any available extra horizontal space.

View gtk4 documentation

Parameters:

Returns:

method set_size_request

function set_size_request(size: [integer?, integer?]) -> nil

Sets the minimum size of a widget.

That is, the widget’s size request will be at least width by height. You can use this function to force a widget to be larger than it normally would be.

If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.

See also: set_width_request, set_height_request.

View gtk4 documentation

Parameters:

  • size

    ([integer?, integer?])

Returns:

method set_valign

function set_valign(valign: 'Baseline'|'Center'|'End'|'Fill'|'Start'...(+1)) -> nil

Sets the vertical alignment of widget.

View gtk4 documentation

valign:
    | 'Fill'
    | 'Start'
    | 'End'
    | 'Center'
    | 'Baseline'

Parameters:

Returns:

method set_vexpand

function set_vexpand(vexpand: boolean) -> nil

Sets whether the widget would like any available extra vertical space.

View gtk4 documentation

Parameters:

Returns:

method set_width_request

function set_width_request(width: integer?) -> nil

Sets the minimum width of a widget.

That is, the widget’s size request will be at least width. You can use this function to force a widget to be wider than it normally would be.

If the width request in a given direction is -1 (unset), then the “natural” width request of the widget will be used instead.

See also: set_height_request, set_size_request.

View gtk4 documentation

Parameters:

Returns: