1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 06:41:03 +02:00
ironbar/src/clients/upower/mod.rs

35 lines
939 B
Rust
Raw Normal View History

mod device;
mod upower;
use crate::clients::ClientResult;
use crate::register_fallible_client;
2023-03-19 02:16:49 +05:30
use std::sync::Arc;
use upower::UPowerProxy;
2023-03-19 02:16:49 +05:30
use zbus::fdo::PropertiesProxy;
use zbus::proxy::CacheProperties;
pub use device::BatteryState;
2023-03-19 02:16:49 +05:30
pub async fn create_display_proxy() -> ClientResult<PropertiesProxy<'static>> {
let dbus = Box::pin(zbus::Connection::system()).await?;
2023-03-19 02:16:49 +05:30
let device_proxy = UPowerProxy::new(&dbus).await?;
2023-03-19 02:16:49 +05:30
let display_device = device_proxy.get_display_device().await?;
2023-03-19 02:16:49 +05:30
let path = display_device.inner().path();
2023-03-19 02:16:49 +05:30
let proxy = PropertiesProxy::builder(&dbus)
.destination("org.freedesktop.UPower")
.expect("failed to set proxy destination address")
.path(path)
.expect("failed to set proxy path")
.cache_properties(CacheProperties::No)
.build()
.await?;
2023-03-19 02:16:49 +05:30
Ok(Arc::new(proxy))
2023-03-19 02:16:49 +05:30
}
register_fallible_client!(PropertiesProxy<'static>, upower);