From cff6303b6c90a02eec89036956a34055f0c06f7f Mon Sep 17 00:00:00 2001 From: Jeremy Whiting Date: Wed, 28 May 2025 13:25:50 -0600 Subject: [PATCH] screenreader: add screen reader commands to steamosctl. Adds get-screen-reader-enabled, set-screen-reader-enabled, get-screen-reader-(pitch|rate|volume), set-screen-reader-(pitch|rate|volume). --- src/bin/steamosctl.rs | 78 ++++++++++++++++++++++++++++++++++++-- src/proxy/mod.rs | 2 + src/proxy/screenreader0.rs | 45 ++++++++++++++++++++++ 3 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 src/proxy/screenreader0.rs diff --git a/src/bin/steamosctl.rs b/src/bin/steamosctl.rs index e437ce1..d0b3627 100644 --- a/src/bin/steamosctl.rs +++ b/src/bin/steamosctl.rs @@ -6,7 +6,7 @@ */ use anyhow::Result; -use clap::{Parser, Subcommand}; +use clap::{ArgAction, Parser, Subcommand}; use itertools::Itertools; use std::collections::HashMap; use std::io::Cursor; @@ -16,8 +16,8 @@ use steamos_manager::power::{CPUScalingGovernor, GPUPerformanceLevel, GPUPowerPr use steamos_manager::proxy::{ AmbientLightSensor1Proxy, BatteryChargeLimit1Proxy, CpuScaling1Proxy, FactoryReset1Proxy, FanControl1Proxy, GpuPerformanceLevel1Proxy, GpuPowerProfile1Proxy, HdmiCec1Proxy, - LowPowerMode1Proxy, Manager2Proxy, PerformanceProfile1Proxy, Storage1Proxy, TdpLimit1Proxy, - UpdateBios1Proxy, UpdateDock1Proxy, WifiDebug1Proxy, WifiDebugDump1Proxy, + LowPowerMode1Proxy, Manager2Proxy, PerformanceProfile1Proxy, ScreenReader0Proxy, Storage1Proxy, + TdpLimit1Proxy, UpdateBios1Proxy, UpdateDock1Proxy, WifiDebug1Proxy, WifiDebugDump1Proxy, WifiPowerManagement1Proxy, }; use steamos_manager::wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement}; @@ -206,6 +206,42 @@ enum Commands { /// Get the model and variant of this device, if known GetDeviceModel, + + /// Get whether screen reader is enabled or not. + GetScreenReaderEnabled, + + /// Enable or disable the screen reader + SetScreenReaderEnabled { + #[arg(action = ArgAction::Set, required = true)] + enable: bool, + }, + + /// Get screen reader rate + GetScreenReaderRate, + + /// Set screen reader rate + SetScreenReaderRate { + /// Valid rates between 0.0 for slowest and 100.0 for fastest. + rate: f64, + }, + + /// Get screen reader pitch + GetScreenReaderPitch, + + /// Set screen reader pitch + SetScreenReaderPitch { + /// Valid pitches between 0.0 for lowest and 10.0 for highest. + pitch: f64, + }, + + /// Get screen reader volume + GetScreenReaderVolume, + + /// Set screen reader volume + SetScreenReaderVolume { + /// Valid volume between 0.0 for off, and 10.0 for loudest. + volume: f64, + }, } async fn get_all_properties(conn: &Connection) -> Result<()> { @@ -519,6 +555,42 @@ async fn main() -> Result<()> { println!("Model: {device}"); println!("Variant: {variant}"); } + Commands::GetScreenReaderEnabled => { + let proxy = ScreenReader0Proxy::new(&conn).await?; + let enabled = proxy.enabled().await?; + println!("Enabled: {enabled}"); + } + Commands::SetScreenReaderEnabled { enable } => { + let proxy = ScreenReader0Proxy::new(&conn).await?; + proxy.set_enabled(*enable).await?; + } + Commands::GetScreenReaderRate => { + let proxy = ScreenReader0Proxy::new(&conn).await?; + let rate = proxy.rate().await?; + println!("Rate: {rate}"); + } + Commands::SetScreenReaderRate { rate } => { + let proxy = ScreenReader0Proxy::new(&conn).await?; + proxy.set_rate(*rate).await?; + } + Commands::GetScreenReaderPitch => { + let proxy = ScreenReader0Proxy::new(&conn).await?; + let pitch = proxy.pitch().await?; + println!("Pitch: {pitch}"); + } + Commands::SetScreenReaderPitch { pitch } => { + let proxy = ScreenReader0Proxy::new(&conn).await?; + proxy.set_pitch(*pitch).await?; + } + Commands::GetScreenReaderVolume => { + let proxy = ScreenReader0Proxy::new(&conn).await?; + let volume = proxy.volume().await?; + println!("Volume: {volume}"); + } + Commands::SetScreenReaderVolume { volume } => { + let proxy = ScreenReader0Proxy::new(&conn).await?; + proxy.set_volume(*volume).await?; + } } Ok(()) diff --git a/src/proxy/mod.rs b/src/proxy/mod.rs index f0e0704..f8c0acf 100644 --- a/src/proxy/mod.rs +++ b/src/proxy/mod.rs @@ -25,6 +25,7 @@ mod hdmi_cec1; mod low_power_mode1; mod manager2; mod performance_profile1; +mod screenreader0; mod storage1; mod tdp_limit1; mod update_bios1; @@ -43,6 +44,7 @@ pub use crate::proxy::hdmi_cec1::HdmiCec1Proxy; pub use crate::proxy::low_power_mode1::LowPowerMode1Proxy; pub use crate::proxy::manager2::Manager2Proxy; pub use crate::proxy::performance_profile1::PerformanceProfile1Proxy; +pub use crate::proxy::screenreader0::ScreenReader0Proxy; pub use crate::proxy::storage1::Storage1Proxy; pub use crate::proxy::tdp_limit1::TdpLimit1Proxy; pub use crate::proxy::update_bios1::UpdateBios1Proxy; diff --git a/src/proxy/screenreader0.rs b/src/proxy/screenreader0.rs new file mode 100644 index 0000000..6edc553 --- /dev/null +++ b/src/proxy/screenreader0.rs @@ -0,0 +1,45 @@ +//! # D-Bus interface proxy for: `com.steampowered.SteamOSManager1.ScreenReader0` +//! +//! This code was generated by `zbus-xmlgen` `5.1.0` from D-Bus introspection data. +//! Source: `com.steampowered.SteamOSManager1.xml`. +//! +//! You may prefer to adapt it, instead of using it verbatim. +//! +//! More information can be found in the [Writing a client proxy] section of the zbus +//! documentation. +//! +//! +//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html +//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces, +use zbus::proxy; +#[proxy( + interface = "com.steampowered.SteamOSManager1.ScreenReader0", + default_service = "com.steampowered.SteamOSManager1", + default_path = "/com/steampowered/SteamOSManager1", + assume_defaults = true +)] +pub trait ScreenReader0 { + /// Enabled property + #[zbus(property)] + fn enabled(&self) -> zbus::Result; + #[zbus(property)] + fn set_enabled(&self, value: bool) -> zbus::Result<()>; + + /// Pitch property + #[zbus(property)] + fn pitch(&self) -> zbus::Result; + #[zbus(property)] + fn set_pitch(&self, value: f64) -> zbus::Result<()>; + + /// Rate property + #[zbus(property)] + fn rate(&self) -> zbus::Result; + #[zbus(property)] + fn set_rate(&self, value: f64) -> zbus::Result<()>; + + /// Volume property + #[zbus(property)] + fn volume(&self) -> zbus::Result; + #[zbus(property)] + fn set_volume(&self, value: f64) -> zbus::Result<()>; +}