use super::common::get_brightness;
use crate::DriverCallback;
use crate::DriverContext;
use crate::DriverResult;
use crate::{
DriverCategory,
types::{Driver, DriverParameter},
};
use serde_json::{Value, json};
use std::collections::HashMap;
use tracing::{debug, info};
#[derive(Debug)]
pub struct DisplayControlBrightnessGetDriver;
#[async_trait::async_trait]
impl Driver for DisplayControlBrightnessGetDriver {
fn name(&self) -> &str {
"display_control_brightness_get"
}
fn description(&self) -> &str {
"Get the current display brightness level (laptops only)"
}
fn usage_hint(&self) -> &str {
"Use this skill to get the screen brightness (0-100). Works on laptops, may not work on desktops."
}
fn parameters(&self) -> Vec<DriverParameter> {
return vec![];
}
fn example_call(&self) -> DriverResult<Value> {
return Ok(json!({
"action": "display_control_brightness_get"
}));
}
fn example_output(&self) -> String {
return "Display brightness: 75%".to_string();
}
fn category(&self) -> DriverCategory {
return DriverCategory::Display;
}
async fn execute(
&self,
parameters: &HashMap<String, Value>,
callback: Option<&dyn DriverCallback>,
context: Option<&DriverContext>,
) -> DriverResult<String> {
debug!("Executing display_control_brightness_get driver");
let brightness = get_brightness().map_err(|e| {
debug!("Failed to get brightness: {}", e);
return crate::DriverError::execution(format!("Failed to get brightness: {}", e));
})?;
info!("Current brightness: {}%", brightness);
return Ok(format!("Display brightness: {}%", brightness));
}
}