mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-08 07:30:36 -04:00
manager/user: Expose device and variant info over DBus
This commit is contained in:
parent
b1dc04daa8
commit
2555b95258
4 changed files with 31 additions and 1 deletions
|
@ -219,6 +219,15 @@
|
|||
-->
|
||||
<method name="ReloadConfig"/>
|
||||
|
||||
<!--
|
||||
DeviceModel:
|
||||
|
||||
A tuple of the device model and variant that SteamOS Manager is running
|
||||
on. If the device or variant isn't known the applicable fields will be
|
||||
"unknown" instead.
|
||||
-->
|
||||
<property name="DeviceModel" type="ss" access="read"/>
|
||||
|
||||
</interface>
|
||||
|
||||
<!--
|
||||
|
|
|
@ -184,6 +184,9 @@ enum Commands {
|
|||
|
||||
/// Reload the configuration from disk
|
||||
ReloadConfig,
|
||||
|
||||
/// Get the model and variant of this device, if known
|
||||
GetDeviceModel,
|
||||
}
|
||||
|
||||
async fn get_all_properties(conn: &Connection) -> Result<()> {
|
||||
|
@ -462,6 +465,12 @@ async fn main() -> Result<()> {
|
|||
let proxy = Manager2Proxy::new(&conn).await?;
|
||||
proxy.reload_config().await?;
|
||||
}
|
||||
Commands::GetDeviceModel => {
|
||||
let proxy = Manager2Proxy::new(&conn).await?;
|
||||
let (device, variant) = proxy.device_model().await?;
|
||||
println!("Model: {device}");
|
||||
println!("Variant: {variant}");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -19,7 +19,9 @@ use crate::cec::{HdmiCecControl, HdmiCecState};
|
|||
use crate::daemon::user::Command;
|
||||
use crate::daemon::DaemonCommand;
|
||||
use crate::error::{to_zbus_error, to_zbus_fdo_error, zbus_to_zbus_fdo};
|
||||
use crate::hardware::{device_type, steam_deck_variant, DeviceType, SteamDeckVariant};
|
||||
use crate::hardware::{
|
||||
device_type, device_variant, steam_deck_variant, DeviceType, SteamDeckVariant,
|
||||
};
|
||||
use crate::job::JobManagerCommand;
|
||||
use crate::platform::platform_config;
|
||||
use crate::power::{
|
||||
|
@ -440,6 +442,12 @@ impl Manager2 {
|
|||
.map_err(to_zbus_fdo_error)?;
|
||||
method!(self, "ReloadConfig")
|
||||
}
|
||||
|
||||
#[zbus(property(emits_changed_signal = "const"))]
|
||||
async fn device_model(&self) -> fdo::Result<(String, String)> {
|
||||
let (device, variant) = device_variant().await.map_err(to_zbus_fdo_error)?;
|
||||
Ok((device.to_string(), variant))
|
||||
}
|
||||
}
|
||||
|
||||
#[interface(name = "com.steampowered.SteamOSManager1.Storage1")]
|
||||
|
|
|
@ -21,4 +21,8 @@ use zbus::proxy;
|
|||
pub trait Manager2 {
|
||||
/// ReloadConfig method
|
||||
fn reload_config(&self) -> zbus::Result<()>;
|
||||
|
||||
/// DeviceModel property
|
||||
#[zbus(property)]
|
||||
fn device_model(&self) -> zbus::Result<(String, String)>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue