Add greeter keyboard and user selection (#55)

* Add greeter keyboard and user selection

Fixes #37
Fixes #38

* Support switching users and add tooltips to icon buttons

* Implement switching users

* Implement keyboard layout switching

* Ensure that user's xkb_config is used
This commit is contained in:
Jeremy Soller 2024-06-04 22:17:44 -06:00 committed by GitHub
parent 4653bb1de9
commit f6ccf0146e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 481 additions and 148 deletions

View file

@ -1,4 +1,5 @@
pub use cosmic_bg_config::Color;
pub use cosmic_comp_config::XkbConfig;
pub use cosmic_theme::Theme;
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
@ -9,6 +10,7 @@ pub struct UserData {
pub icon_opt: Option<Vec<u8>>,
pub theme_opt: Option<Theme>,
pub wallpapers_opt: Option<Vec<(String, WallpaperData)>>,
pub xkb_config_opt: Option<XkbConfig>,
}
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]

View file

@ -1,4 +1,5 @@
use cosmic_bg_config::Source;
use cosmic_comp_config::CosmicCompConfig;
use cosmic_config::CosmicConfigEntry;
use cosmic_greeter_daemon::{UserData, WallpaperData};
use std::{env, error::Error, fs, future::pending, io, path::Path};
@ -113,6 +114,7 @@ impl GreeterProxy {
theme_opt: None,
//TODO: should wallpapers come from a per-user call?
wallpapers_opt: None,
xkb_config_opt: None,
};
//IMPORTANT: Assume the identity of the user to ensure we don't read wallpaper file data as root
@ -188,6 +190,24 @@ impl GreeterProxy {
}
user_data.wallpapers_opt = Some(wallpaper_datas);
}
match cosmic_config::Config::new(
"com.system76.CosmicComp",
CosmicCompConfig::VERSION,
) {
Ok(config_handler) => match CosmicCompConfig::get_entry(&config_handler) {
Ok(config) => {
user_data.xkb_config_opt = Some(config.xkb_config);
}
Err((errs, config)) => {
log::error!("errors loading cosmic-comp config: {:?}", errs);
user_data.xkb_config_opt = Some(config.xkb_config);
}
},
Err(err) => {
log::error!("failed to create cosmic-comp config handler: {}", err);
}
};
})
.map_err(|err| GreeterError::RunAsUser(err.to_string()))?;