mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Better everything
This commit is contained in:
@@ -7,3 +7,44 @@ pub mod zbus_platform;
|
||||
pub mod zbus_slash;
|
||||
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
pub fn list_iface_blocking() -> Result<Vec<String>, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::blocking::Connection::system()?;
|
||||
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/")?;
|
||||
let interfaces = f.get_managed_objects()?;
|
||||
let mut ifaces = Vec::new();
|
||||
for v in interfaces.iter() {
|
||||
for k in v.1.keys() {
|
||||
ifaces.push(k.to_string());
|
||||
}
|
||||
}
|
||||
Ok(ifaces)
|
||||
}
|
||||
|
||||
pub fn has_iface_blocking(iface: &str) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::blocking::Connection::system()?;
|
||||
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/")?;
|
||||
let interfaces = f.get_managed_objects()?;
|
||||
for v in interfaces.iter() {
|
||||
for k in v.1.keys() {
|
||||
if k.as_str() == iface {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
pub async fn has_iface(iface: &str) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
let conn = zbus::Connection::system().await?;
|
||||
let f = zbus::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").await?;
|
||||
let interfaces = f.get_managed_objects().await?;
|
||||
for v in interfaces.iter() {
|
||||
for k in v.1.keys() {
|
||||
if k.as_str() == iface {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
@@ -36,9 +36,6 @@ trait Platform {
|
||||
/// NextThrottleThermalPolicy method
|
||||
fn next_throttle_thermal_policy(&self) -> zbus::Result<()>;
|
||||
|
||||
/// SupportedInterfaces method
|
||||
fn supported_interfaces(&self) -> zbus::Result<Vec<String>>;
|
||||
|
||||
/// SupportedProperties method
|
||||
fn supported_properties(&self) -> zbus::Result<Vec<Properties>>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user