mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Fix: ROGCC: fix anime matrix settings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
pub use asusd::{DBUS_IFACE, DBUS_NAME, DBUS_PATH};
|
||||
use zbus::proxy::ProxyImpl;
|
||||
|
||||
pub mod asus_armoury;
|
||||
pub mod scsi_aura;
|
||||
@@ -50,3 +51,42 @@ pub async fn has_iface(iface: &str) -> Result<bool, Box<dyn std::error::Error>>
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
pub async fn find_iface_async<T>(iface_name: &str) -> Result<Vec<T>, Box<dyn std::error::Error>>
|
||||
where
|
||||
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>
|
||||
{
|
||||
let conn = zbus::Connection::system().await?;
|
||||
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").await?;
|
||||
let interfaces = f.get_managed_objects().await?;
|
||||
let mut paths = Vec::new();
|
||||
for v in interfaces.iter() {
|
||||
// let o: Vec<zbus::names::OwnedInterfaceName> = v.1.keys().map(|e|
|
||||
// e.to_owned()).collect(); println!("{}, {:?}", v.0, o);
|
||||
for k in v.1.keys() {
|
||||
if k.as_str() == iface_name {
|
||||
// println!("Found {iface_name} device at {}, {}", v.0, k);
|
||||
paths.push(v.0.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
if paths.len() > 1 {
|
||||
println!("Multiple asusd interfaces devices found");
|
||||
}
|
||||
if !paths.is_empty() {
|
||||
let mut ctrl = Vec::new();
|
||||
paths.sort_by(|a, b| a.cmp(b));
|
||||
for path in paths {
|
||||
ctrl.push(
|
||||
T::builder(&conn)
|
||||
.path(path.clone())?
|
||||
.destination("xyz.ljones.Asusd")?
|
||||
.build()
|
||||
.await?
|
||||
);
|
||||
}
|
||||
return Ok(ctrl);
|
||||
}
|
||||
|
||||
Err(format!("Did not find {iface_name}").into())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user