mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-10 00:20:29 -04:00
steamosctl: Make -a into get-all-properties command instead of a flag
This commit is contained in:
parent
01b50984a4
commit
fa80c861ad
1 changed files with 48 additions and 50 deletions
|
@ -19,15 +19,15 @@ use zbus::{zvariant, Connection};
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Optionally get all properties
|
|
||||||
#[arg(short, long)]
|
|
||||||
all_properties: bool,
|
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Option<Commands>,
|
command: Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
enum Commands {
|
enum Commands {
|
||||||
|
/// Get all properties
|
||||||
|
GetAllProperties,
|
||||||
|
|
||||||
/// Get luminance sensor calibration gain
|
/// Get luminance sensor calibration gain
|
||||||
GetAlsCalibrationGain,
|
GetAlsCalibrationGain,
|
||||||
|
|
||||||
|
@ -148,83 +148,82 @@ async fn main() -> Result<()> {
|
||||||
let conn = Connection::session().await?;
|
let conn = Connection::session().await?;
|
||||||
let proxy = ManagerProxy::builder(&conn).build().await?;
|
let proxy = ManagerProxy::builder(&conn).build().await?;
|
||||||
|
|
||||||
if args.all_properties {
|
|
||||||
let properties_proxy = PropertiesProxy::new(
|
|
||||||
&conn,
|
|
||||||
"com.steampowered.SteamOSManager1",
|
|
||||||
"/com/steampowered/SteamOSManager1",
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
let name = InterfaceName::try_from("com.steampowered.SteamOSManager1.Manager")?;
|
|
||||||
let properties = properties_proxy
|
|
||||||
.get_all(zvariant::Optional::from(Some(name)))
|
|
||||||
.await?;
|
|
||||||
for key in properties.keys().sorted() {
|
|
||||||
let value = &properties[key];
|
|
||||||
let val = value.deref();
|
|
||||||
println!("{key}: {val}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then process arguments
|
// Then process arguments
|
||||||
match &args.command {
|
match &args.command {
|
||||||
Some(Commands::GetAlsCalibrationGain) => {
|
Commands::GetAllProperties => {
|
||||||
|
let properties_proxy = PropertiesProxy::new(
|
||||||
|
&conn,
|
||||||
|
"com.steampowered.SteamOSManager1",
|
||||||
|
"/com/steampowered/SteamOSManager1",
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
let name = InterfaceName::try_from("com.steampowered.SteamOSManager1.Manager")?;
|
||||||
|
let properties = properties_proxy
|
||||||
|
.get_all(zvariant::Optional::from(Some(name)))
|
||||||
|
.await?;
|
||||||
|
for key in properties.keys().sorted() {
|
||||||
|
let value = &properties[key];
|
||||||
|
let val = value.deref();
|
||||||
|
println!("{key}: {val}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Commands::GetAlsCalibrationGain => {
|
||||||
let gain = proxy.als_calibration_gain().await?;
|
let gain = proxy.als_calibration_gain().await?;
|
||||||
println!("ALS calibration gain: {gain}");
|
println!("ALS calibration gain: {gain}");
|
||||||
}
|
}
|
||||||
Some(Commands::GetHardwareCurrentlySupported) => {
|
Commands::GetHardwareCurrentlySupported => {
|
||||||
let supported = proxy.hardware_currently_supported().await?;
|
let supported = proxy.hardware_currently_supported().await?;
|
||||||
println!("Hardware currently supported: {supported}");
|
println!("Hardware currently supported: {supported}");
|
||||||
}
|
}
|
||||||
Some(Commands::GetVersion) => {
|
Commands::GetVersion => {
|
||||||
let version = proxy.version().await?;
|
let version = proxy.version().await?;
|
||||||
println!("Version: {version}");
|
println!("Version: {version}");
|
||||||
}
|
}
|
||||||
Some(Commands::SetFanControlState { state }) => {
|
Commands::SetFanControlState { state } => {
|
||||||
proxy.set_fan_control_state(*state).await?;
|
proxy.set_fan_control_state(*state).await?;
|
||||||
}
|
}
|
||||||
Some(Commands::SetGPUPerformanceLevel { level }) => {
|
Commands::SetGPUPerformanceLevel { level } => {
|
||||||
proxy.set_gpu_performance_level(*level).await?;
|
proxy.set_gpu_performance_level(*level).await?;
|
||||||
}
|
}
|
||||||
Some(Commands::GetGPUPerformanceLevel) => {
|
Commands::GetGPUPerformanceLevel => {
|
||||||
let level = proxy.gpu_performance_level().await?;
|
let level = proxy.gpu_performance_level().await?;
|
||||||
println!("GPU performance level: {level}");
|
println!("GPU performance level: {level}");
|
||||||
}
|
}
|
||||||
Some(Commands::SetManualGPUClock { freq }) => {
|
Commands::SetManualGPUClock { freq } => {
|
||||||
proxy.set_manual_gpu_clock(*freq).await?;
|
proxy.set_manual_gpu_clock(*freq).await?;
|
||||||
}
|
}
|
||||||
Some(Commands::GetManualGPUClock) => {
|
Commands::GetManualGPUClock => {
|
||||||
let clock = proxy.manual_gpu_clock().await?;
|
let clock = proxy.manual_gpu_clock().await?;
|
||||||
println!("Manual GPU Clock: {clock}");
|
println!("Manual GPU Clock: {clock}");
|
||||||
}
|
}
|
||||||
Some(Commands::GetManualGPUClockMax) => {
|
Commands::GetManualGPUClockMax => {
|
||||||
let value = proxy.manual_gpu_clock_max().await?;
|
let value = proxy.manual_gpu_clock_max().await?;
|
||||||
println!("Manual GPU Clock Max: {value}");
|
println!("Manual GPU Clock Max: {value}");
|
||||||
}
|
}
|
||||||
Some(Commands::GetManualGPUClockMin) => {
|
Commands::GetManualGPUClockMin => {
|
||||||
let value = proxy.manual_gpu_clock_min().await?;
|
let value = proxy.manual_gpu_clock_min().await?;
|
||||||
println!("Manual GPU Clock Min: {value}");
|
println!("Manual GPU Clock Min: {value}");
|
||||||
}
|
}
|
||||||
Some(Commands::SetTDPLimit { limit }) => {
|
Commands::SetTDPLimit { limit } => {
|
||||||
proxy.set_tdp_limit(*limit).await?;
|
proxy.set_tdp_limit(*limit).await?;
|
||||||
}
|
}
|
||||||
Some(Commands::GetTDPLimit) => {
|
Commands::GetTDPLimit => {
|
||||||
let limit = proxy.tdp_limit().await?;
|
let limit = proxy.tdp_limit().await?;
|
||||||
println!("TDP limit: {limit}");
|
println!("TDP limit: {limit}");
|
||||||
}
|
}
|
||||||
Some(Commands::GetFanControlState) => {
|
Commands::GetFanControlState => {
|
||||||
let state = proxy.fan_control_state().await?;
|
let state = proxy.fan_control_state().await?;
|
||||||
println!("Fan control state: {state}");
|
println!("Fan control state: {state}");
|
||||||
}
|
}
|
||||||
Some(Commands::GetTDPLimitMax) => {
|
Commands::GetTDPLimitMax => {
|
||||||
let value = proxy.tdp_limit_max().await?;
|
let value = proxy.tdp_limit_max().await?;
|
||||||
println!("TDP limit max: {value}");
|
println!("TDP limit max: {value}");
|
||||||
}
|
}
|
||||||
Some(Commands::GetTDPLimitMin) => {
|
Commands::GetTDPLimitMin => {
|
||||||
let value = proxy.tdp_limit_min().await?;
|
let value = proxy.tdp_limit_min().await?;
|
||||||
println!("TDP limit min: {value}");
|
println!("TDP limit min: {value}");
|
||||||
}
|
}
|
||||||
Some(Commands::SetWifiBackend { backend }) => match WifiBackend::from_str(backend) {
|
Commands::SetWifiBackend { backend } => match WifiBackend::from_str(backend) {
|
||||||
Ok(b) => {
|
Ok(b) => {
|
||||||
proxy.set_wifi_backend(b as u32).await?;
|
proxy.set_wifi_backend(b as u32).await?;
|
||||||
}
|
}
|
||||||
|
@ -232,45 +231,44 @@ async fn main() -> Result<()> {
|
||||||
println!("Unknown wifi backend {backend}");
|
println!("Unknown wifi backend {backend}");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Some(Commands::GetWifiBackend) => {
|
Commands::GetWifiBackend => {
|
||||||
let backend = proxy.wifi_backend().await?;
|
let backend = proxy.wifi_backend().await?;
|
||||||
let backend_string = WifiBackend::try_from(backend).unwrap().to_string();
|
let backend_string = WifiBackend::try_from(backend).unwrap().to_string();
|
||||||
println!("Wifi backend: {backend_string}");
|
println!("Wifi backend: {backend_string}");
|
||||||
}
|
}
|
||||||
Some(Commands::SetWifiDebugMode { mode, buffer }) => {
|
Commands::SetWifiDebugMode { mode, buffer } => {
|
||||||
proxy.set_wifi_debug_mode(*mode, *buffer).await?;
|
proxy.set_wifi_debug_mode(*mode, *buffer).await?;
|
||||||
}
|
}
|
||||||
Some(Commands::GetWifiDebugMode) => {
|
Commands::GetWifiDebugMode => {
|
||||||
let mode = proxy.wifi_debug_mode_state().await?;
|
let mode = proxy.wifi_debug_mode_state().await?;
|
||||||
println!("Wifi debug mode: {mode}");
|
println!("Wifi debug mode: {mode}");
|
||||||
}
|
}
|
||||||
Some(Commands::SetWifiPowerManagementState { state }) => {
|
Commands::SetWifiPowerManagementState { state } => {
|
||||||
proxy.set_wifi_power_management_state(*state).await?;
|
proxy.set_wifi_power_management_state(*state).await?;
|
||||||
}
|
}
|
||||||
Some(Commands::GetWifiPowerManagementState) => {
|
Commands::GetWifiPowerManagementState => {
|
||||||
let state = proxy.wifi_power_management_state().await?;
|
let state = proxy.wifi_power_management_state().await?;
|
||||||
println!("Wifi power management state: {state}");
|
println!("Wifi power management state: {state}");
|
||||||
}
|
}
|
||||||
Some(Commands::SetHdmiCecState { state }) => {
|
Commands::SetHdmiCecState { state } => {
|
||||||
proxy.set_hdmi_cec_state(*state).await?;
|
proxy.set_hdmi_cec_state(*state).await?;
|
||||||
}
|
}
|
||||||
Some(Commands::GetHdmiCecState) => {
|
Commands::GetHdmiCecState => {
|
||||||
let state = proxy.hdmi_cec_state().await?;
|
let state = proxy.hdmi_cec_state().await?;
|
||||||
println!("HDMI-CEC state: {state}");
|
println!("HDMI-CEC state: {state}");
|
||||||
}
|
}
|
||||||
Some(Commands::UpdateBios) => {
|
Commands::UpdateBios => {
|
||||||
let _ = proxy.update_bios().await?;
|
let _ = proxy.update_bios().await?;
|
||||||
}
|
}
|
||||||
Some(Commands::UpdateDock) => {
|
Commands::UpdateDock => {
|
||||||
let _ = proxy.update_dock().await?;
|
let _ = proxy.update_dock().await?;
|
||||||
}
|
}
|
||||||
Some(Commands::FactoryReset) => {
|
Commands::FactoryReset => {
|
||||||
let _ = proxy.prepare_factory_reset().await?;
|
let _ = proxy.prepare_factory_reset().await?;
|
||||||
}
|
}
|
||||||
Some(Commands::TrimDevices) => {
|
Commands::TrimDevices => {
|
||||||
let _ = proxy.trim_devices().await?;
|
let _ = proxy.trim_devices().await?;
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue