use super::common::get_primary_display;
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 DisplayControlPrimaryGetDriver;
#[async_trait::async_trait]
impl Driver for DisplayControlPrimaryGetDriver {
fn name(&self) -> &str {
"display_control_primary_get"
}
fn description(&self) -> &str {
"Get information about the primary display"
}
fn usage_hint(&self) -> &str {
"Use this skill to get details about the main monitor."
}
fn parameters(&self) -> Vec<DriverParameter> {
return vec![];
}
fn example_call(&self) -> DriverResult<Value> {
return Ok(json!({
"action": "display_control_primary_get"
}));
}
fn example_output(&self) -> String {
return "Primary display: Primary Display (1920x1080, 60Hz)".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_primary_get driver");
let d = get_primary_display().map_err(|e| {
debug!("Failed to get primary display: {}", e);
return crate::DriverError::execution(format!("Failed to get primary display: {}", e));
})?;
info!("Primary display: {:?} ({:?}x{:?} @ {}Hz)", d.name, d.width, d.height, d.refresh_rate);
return Ok(format!("Primary display: {} ({}x{} @ {}Hz)", d.name, d.width, d.height, d.refresh_rate));
}
}