improv(input-sources): gracefully exit if keyboard layouts data could not be obtained

This commit is contained in:
Michael Aaron Murphy 2024-05-06 15:19:40 +02:00 committed by Michael Murphy
parent 33cb23f04f
commit b9308af4b7
3 changed files with 18 additions and 5 deletions

View file

@ -9,6 +9,15 @@ mod localize;
mod window;
pub fn run() -> cosmic::iced::Result {
localize::localize();
let layouts = match xkb_data::keyboard_layouts() {
Ok(layouts) => layouts,
Err(why) => {
tracing::error!("could not get keyboard layouts data: {:?}", why);
return Ok(());
}
};
let (config_handler, config) = match cosmic_config::Config::new(window::ID, CONFIG_VERSION) {
Ok(config_handler) => {
let config = match Config::get_entry(&config_handler) {
@ -46,8 +55,9 @@ pub fn run() -> cosmic::iced::Result {
let flags = Flags {
comp_config,
comp_config_handler,
config_handler: config_handler,
config: config,
config_handler,
config,
layouts,
};
cosmic::applet::run::<Window>(true, flags)
}