fix(graphics): exit if connection to com.system76.PowerDaemon fails
This commit is contained in:
parent
2d1b8680f9
commit
28446a33ab
2 changed files with 9 additions and 1 deletions
|
|
@ -89,5 +89,9 @@ pub async fn init() -> Option<(Connection, PowerDaemonProxy<'static>)> {
|
|||
_ => return None,
|
||||
};
|
||||
|
||||
if matches!(proxy.introspect().await, Err(zbus::fdo::Error::ServiceUnknown(_))) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some((conn, proxy))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ impl cosmic::Application for Window {
|
|||
}
|
||||
}
|
||||
Message::DBusInit(dbus) => {
|
||||
if dbus.is_none() {
|
||||
eprintln!("Could not connect to com.system76.PowerDaemon. Exiting.");
|
||||
std::process::exit(0);
|
||||
}
|
||||
self.dbus = dbus;
|
||||
return iced::Command::perform(
|
||||
get_current_graphics(self.dbus.as_ref().unwrap().1.clone()),
|
||||
|
|
@ -139,7 +143,7 @@ impl cosmic::Application for Window {
|
|||
Message::CurrentGraphics(match cur_graphics {
|
||||
Ok(g) => Some(g),
|
||||
Err(err) => {
|
||||
eprintln!("{err}");
|
||||
eprintln!("{err:?}");
|
||||
None
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue