Skip to main content

Crate tauri_plugin_brightness

Crate tauri_plugin_brightness 

Source
Expand description

Control display brightness through DDC/CI and the Linux kernel backlight.

The plugin is a thin layer over the tauri-brightness-core crate: it exposes the same operations as commands, adds the permission definitions Tauri requires, and ships JavaScript bindings.

§Setup

tauri::Builder::default().plugin(tauri_plugin_brightness::init());

The plugin can also be used directly from Rust, through the BrightnessExt extension trait:

use tauri::Manager;
use tauri_plugin_brightness::BrightnessExt;

let monitors = app.brightness().list_monitors();
println!("{} display(s) detected", monitors.len());

§Permissions

The commands are not reachable from the webview until they are allowed by a capability. default.toml allows all of them, so the common case only needs the plugin to be registered:

{
  "permissions": ["brightness:default"]
}

Grant brightness:allow-set-brightness alone when an application should be able to change brightness but not read it.

§Linux permissions

DDC/CI needs the i2c-dev kernel module and usually membership of the i2c group. Internal panels need neither. When no display is detected, the diagnose command reports exactly which piece is missing.

Re-exports§

pub use models::BrightnessPayload;

Modules§

models
Data types shared with the JavaScript bindings. Data types shared between the commands, the desktop implementation and the JavaScript bindings.

Structs§

Diagnostics
Result of probing the system for brightness capabilities.
MonitorInfo
A display whose brightness can be read and written.

Enums§

Backend
Which mechanism a display is driven through.
Error
Errors returned by the plugin commands.

Traits§

BrightnessExt
Extends a Tauri manager with access to the brightness API.

Functions§

init
Initializes the plugin.

Type Aliases§

Result
Alias for a Result with the error type Error.