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,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if matches!(proxy.introspect().await, Err(zbus::fdo::Error::ServiceUnknown(_))) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
Some((conn, proxy))
|
Some((conn, proxy))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,10 @@ impl cosmic::Application for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::DBusInit(dbus) => {
|
Message::DBusInit(dbus) => {
|
||||||
|
if dbus.is_none() {
|
||||||
|
eprintln!("Could not connect to com.system76.PowerDaemon. Exiting.");
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
self.dbus = dbus;
|
self.dbus = dbus;
|
||||||
return iced::Command::perform(
|
return iced::Command::perform(
|
||||||
get_current_graphics(self.dbus.as_ref().unwrap().1.clone()),
|
get_current_graphics(self.dbus.as_ref().unwrap().1.clone()),
|
||||||
|
|
@ -139,7 +143,7 @@ impl cosmic::Application for Window {
|
||||||
Message::CurrentGraphics(match cur_graphics {
|
Message::CurrentGraphics(match cur_graphics {
|
||||||
Ok(g) => Some(g),
|
Ok(g) => Some(g),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("{err}");
|
eprintln!("{err:?}");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue