mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01:04 +02:00
fix(upower): avoid panic on client init error
This commit is contained in:
parent
9d125353c4
commit
474e1fe364
4 changed files with 25 additions and 24 deletions
|
@ -164,12 +164,17 @@ impl Clients {
|
|||
}
|
||||
|
||||
#[cfg(feature = "upower")]
|
||||
pub fn upower(&mut self) -> Arc<zbus::fdo::PropertiesProxy<'static>> {
|
||||
self.upower
|
||||
.get_or_insert_with(|| {
|
||||
crate::await_sync(async { upower::create_display_proxy().await })
|
||||
})
|
||||
.clone()
|
||||
pub fn upower(&mut self) -> ClientResult<zbus::fdo::PropertiesProxy<'static>> {
|
||||
let client = match &self.upower {
|
||||
Some(client) => client.clone(),
|
||||
None => {
|
||||
let client = await_sync(async { upower::create_display_proxy().await })?;
|
||||
self.upower.replace(client.clone());
|
||||
client
|
||||
}
|
||||
};
|
||||
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
#[cfg(feature = "volume")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue