ScreenBrightness service
Create or retrieve this service with page.screen_brightness(**properties). Ruflet reuses the registered service unless you supply a different id.
Example
status = text(value: "Reading brightness…")
page.add(status)
brightness = page.screen_brightness
brightness.get_application_screen_brightness(on_result: ->(value, error) {
next page.update(status, value: error.to_s) if error
brightness.set_application_screen_brightness(0.8, on_result: ->(_result, set_error) {
message = set_error ? set_error.to_s : "Brightness changed from #{value} to 0.8"
page.update(status, value: message)
})
})
Page accessor
page.screen_brightness(**props)
Properties
data— Arbitrary value you can attach to the control and read back in handlers.key— Stable identity used to preserve state across rebuilds.
Events
on_application_screen_brightness_change— Fired on application screen brightness change.on_system_screen_brightness_change— Fired on system screen brightness change.
Page proxy methods
Calling page.screen_brightness with no properties returns a focused proxy with these methods:
can_change_system_screen_brightness(timeout: ..., on_result: ...)get_application_screen_brightness(timeout: ..., on_result: ...)get_system_screen_brightness(timeout: ..., on_result: ...)is_animate(timeout: ..., on_result: ...)is_auto_reset(timeout: ..., on_result: ...)reset_application_screen_brightness(timeout: ..., on_result: ...)set_animate(animate, timeout: ..., on_result: ...)set_application_screen_brightness(brightness, timeout: ..., on_result: ...)set_auto_reset(auto_reset, timeout: ..., on_result: ...)set_system_screen_brightness(brightness, timeout: ..., on_result: ...)
Result and error handling
Client calls are asynchronous. When a method accepts on_result:, handle both callback values: |result, error|. Availability and returned data can vary by platform.
Common service API
The service also supports the common Ruflet control API: attach_handler(event_name, handler), children, emit(event_name, event), has_handler?(event_name), id, merge_props(values = ...), on(event_name, &block), props, runtime_page, runtime_page=, to_patch, type, wire_id, wire_id=.
Use the named methods above for application code; common control methods mainly support event registration, updates, and runtime integration.
Wire reference
- Service helper:
screen_brightness - Wire type:
screenbrightness - Aliases:
screenbrightness