mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
refactor: upgrade to zbus v5
Also drops the deprecated `upower-dbus` crate
This commit is contained in:
parent
75375aa341
commit
63f5954837
10 changed files with 388 additions and 336 deletions
34
src/clients/upower/mod.rs
Normal file
34
src/clients/upower/mod.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
mod device;
|
||||
mod upower;
|
||||
|
||||
use crate::clients::ClientResult;
|
||||
use crate::register_fallible_client;
|
||||
use std::sync::Arc;
|
||||
use upower::UPowerProxy;
|
||||
use zbus::fdo::PropertiesProxy;
|
||||
use zbus::proxy::CacheProperties;
|
||||
|
||||
pub use device::BatteryState;
|
||||
|
||||
pub async fn create_display_proxy() -> ClientResult<PropertiesProxy<'static>> {
|
||||
let dbus = Box::pin(zbus::Connection::system()).await?;
|
||||
|
||||
let device_proxy = UPowerProxy::new(&dbus).await?;
|
||||
|
||||
let display_device = device_proxy.get_display_device().await?;
|
||||
|
||||
let path = display_device.inner().path();
|
||||
|
||||
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?;
|
||||
|
||||
Ok(Arc::new(proxy))
|
||||
}
|
||||
|
||||
register_fallible_client!(PropertiesProxy<'static>, upower);
|
Loading…
Add table
Add a link
Reference in a new issue