feat: introduce cosmic-greeter-start for state cleanup
This commit is contained in:
parent
a57b460733
commit
db59a72eb9
5 changed files with 60 additions and 40 deletions
3
cosmic-greeter-start.sh
Normal file
3
cosmic-greeter-start.sh
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
rm -rf /run/cosmic-greeter/cosmic/com.system76.CosmicSettingsDaemon/v1/*
|
||||
exec cosmic-comp systemd-cat -t cosmic-greeter cosmic-greeter
|
||||
|
|
@ -5,5 +5,5 @@ vt = "1"
|
|||
service = "cosmic-greeter"
|
||||
|
||||
[default_session]
|
||||
command = "cosmic-comp systemd-cat -t cosmic-greeter cosmic-greeter"
|
||||
command = "cosmic-greeter-start"
|
||||
user = "cosmic-greeter"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
|
||||
pub use cosmic_applets_config::time::TimeAppletConfig;
|
||||
pub use cosmic_bg_config::{state::State as BgState, Color, Source as BgSource};
|
||||
pub use cosmic_comp_config::{CosmicCompConfig, XkbConfig};
|
||||
pub use cosmic_comp_config::{CosmicCompConfig, XkbConfig, ZoomConfig};
|
||||
pub use cosmic_theme::{Theme, ThemeBuilder};
|
||||
|
||||
#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize)]
|
||||
|
|
@ -22,6 +22,7 @@ pub struct UserData {
|
|||
pub bg_path_data: BTreeMap<PathBuf, Vec<u8>>,
|
||||
pub xkb_config_opt: Option<XkbConfig>,
|
||||
pub time_applet_config: TimeAppletConfig,
|
||||
pub accessibility_zoom: ZoomConfig,
|
||||
}
|
||||
|
||||
impl UserData {
|
||||
|
|
@ -156,15 +157,19 @@ impl UserData {
|
|||
self.load_wallpapers_as_user();
|
||||
|
||||
match cosmic_config::Config::new("com.system76.CosmicComp", CosmicCompConfig::VERSION) {
|
||||
Ok(config_handler) => match CosmicCompConfig::get_entry(&config_handler) {
|
||||
Ok(config) => {
|
||||
self.xkb_config_opt = Some(config.xkb_config);
|
||||
}
|
||||
Err((errs, config)) => {
|
||||
log::error!("errors loading cosmic-comp config: {:?}", errs);
|
||||
self.xkb_config_opt = Some(config.xkb_config);
|
||||
}
|
||||
},
|
||||
Ok(config_handler) => {
|
||||
match CosmicCompConfig::get_entry(&config_handler) {
|
||||
Ok(config) => {
|
||||
self.xkb_config_opt = Some(config.xkb_config);
|
||||
self.accessibility_zoom = config.accessibility_zoom;
|
||||
}
|
||||
Err((errs, config)) => {
|
||||
log::error!("errors loading cosmic-comp config: {:?}", errs);
|
||||
self.xkb_config_opt = Some(config.xkb_config);
|
||||
self.accessibility_zoom = config.accessibility_zoom;
|
||||
}
|
||||
};
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("failed to create cosmic-comp config handler: {}", err);
|
||||
}
|
||||
|
|
|
|||
6
justfile
6
justfile
|
|
@ -25,6 +25,9 @@ tmpfiles-dst := lib-dir / 'tmpfiles.d' / name + '.conf'
|
|||
daemon-src := cargo-target-dir / 'release' / name + '-daemon'
|
||||
daemon-dst := base-dir / 'bin' / name + '-daemon'
|
||||
|
||||
start-src := name + '-start.sh'
|
||||
start-dst := base-dir / 'bin' / name + '-start'
|
||||
|
||||
dbus-src := 'dbus' / APPID + '.conf'
|
||||
dbus-dst := base-dir / 'share' / 'dbus-1' / 'system.d' / APPID + '.conf'
|
||||
|
||||
|
|
@ -68,6 +71,7 @@ run *args:
|
|||
# The sysusers and tmpfiles files are automatically added
|
||||
install-debian:
|
||||
install -Dm0755 {{bin-src}} {{bin-dst}}
|
||||
install -Dm0755 {{start-src}} {{start-dst}}
|
||||
install -Dm0755 {{daemon-src}} {{daemon-dst}}
|
||||
install -Dm0755 {{dbus-src}} {{dbus-dst}}
|
||||
|
||||
|
|
@ -78,7 +82,7 @@ install: install-debian
|
|||
|
||||
# Uninstalls installed files
|
||||
uninstall:
|
||||
rm {{bin-dst}} {{daemon-dst}} {{dbus-dst}} {{sysusers-dst}} {{tmpfiles-dst}}
|
||||
rm {{start-dst}} {{bin-dst}} {{daemon-dst}} {{dbus-dst}} {{sysusers-dst}} {{tmpfiles-dst}}
|
||||
|
||||
# Vendor dependencies locally
|
||||
vendor:
|
||||
|
|
|
|||
|
|
@ -28,11 +28,12 @@ use cosmic::{
|
|||
iced_runtime::core::window::Id as SurfaceId,
|
||||
theme, widget,
|
||||
};
|
||||
use cosmic::{cosmic_theme::{self, CosmicPalette}, surface};
|
||||
use cosmic_config::CosmicConfigEntry;
|
||||
use cosmic::{
|
||||
cosmic_theme::{self, CosmicPalette},
|
||||
surface,
|
||||
};
|
||||
use cosmic_greeter_config::Config as CosmicGreeterConfig;
|
||||
use cosmic_greeter_daemon::UserData;
|
||||
use cosmic_settings_daemon_config::greeter::GreeterAccessibilityState;
|
||||
use cosmic_settings_subscriptions::cosmic_a11y_manager::{
|
||||
AccessibilityEvent, AccessibilityRequest,
|
||||
};
|
||||
|
|
@ -913,13 +914,17 @@ impl App {
|
|||
self.theme_builder = builder.clone();
|
||||
}
|
||||
|
||||
match &user_data.theme_opt {
|
||||
Some(theme) => {
|
||||
self.accessibility.high_contrast = theme.is_high_contrast;
|
||||
cosmic::command::set_theme(cosmic::Theme::custom(Arc::new(theme.clone())))
|
||||
}
|
||||
None => Task::none(),
|
||||
let mut tasks = Vec::new();
|
||||
self.accessibility.magnifier = user_data.accessibility_zoom.start_on_login;
|
||||
|
||||
if let Some(theme) = &user_data.theme_opt {
|
||||
self.accessibility.high_contrast = theme.is_high_contrast;
|
||||
tasks.push(cosmic::command::set_theme(cosmic::Theme::custom(Arc::new(
|
||||
theme.clone(),
|
||||
))));
|
||||
}
|
||||
|
||||
Task::batch(tasks)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -996,10 +1001,6 @@ impl cosmic::Application for App {
|
|||
let mut accessibility = Accessibility::default();
|
||||
accessibility.helper =
|
||||
cosmic_settings_daemon_config::greeter::GreeterAccessibilityState::config().ok();
|
||||
// Reset the state so that only new changes are applied.
|
||||
if let Some(helper) = accessibility.helper.as_ref() {
|
||||
_ = GreeterAccessibilityState::write_entry(&Default::default(), helper);
|
||||
}
|
||||
|
||||
let app = App {
|
||||
common,
|
||||
|
|
@ -1172,10 +1173,7 @@ impl cosmic::Application for App {
|
|||
}
|
||||
}
|
||||
Message::Reload(new) => {
|
||||
|
||||
return cosmic::command::set_theme(
|
||||
new.clone(),
|
||||
);
|
||||
return cosmic::command::set_theme(new.clone());
|
||||
}
|
||||
Message::Session(selected_session) => {
|
||||
self.selected_session = selected_session;
|
||||
|
|
@ -1514,19 +1512,19 @@ impl cosmic::Application for App {
|
|||
return cosmic::task::future::<_, _>(async move {
|
||||
let builder = builder.clone();
|
||||
let (tx, rx) = tokio::sync::oneshot::channel();
|
||||
std::thread::spawn(move || {
|
||||
match apply_hc_theme(builder, enabled) {
|
||||
Ok(t) => {
|
||||
std::thread::spawn(move || match apply_hc_theme(builder, enabled) {
|
||||
Ok(t) => {
|
||||
_ = tx.send(Some(t));
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("{err:?}");
|
||||
_ = tx.send(None);
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("{err:?}");
|
||||
_ = tx.send(None);
|
||||
}
|
||||
});
|
||||
if let Ok(Some(theme)) = rx.await {
|
||||
cosmic::Action::App(Message::Reload(cosmic::Theme::custom(std::sync::Arc::new(theme))))
|
||||
cosmic::Action::App(Message::Reload(cosmic::Theme::custom(
|
||||
std::sync::Arc::new(theme),
|
||||
)))
|
||||
} else {
|
||||
cosmic::Action::None
|
||||
}
|
||||
|
|
@ -1570,6 +1568,14 @@ impl cosmic::Application for App {
|
|||
self.accessibility.wayland_protocol_version = None;
|
||||
}
|
||||
WaylandUpdate::Started(tx) => {
|
||||
let _ = tx.send(AccessibilityRequest::ScreenFilter {
|
||||
inverted: self.accessibility.invert_colors,
|
||||
filter: None,
|
||||
});
|
||||
let _ = tx.send(AccessibilityRequest::Magnifier(
|
||||
self.accessibility.magnifier,
|
||||
));
|
||||
|
||||
self.accessibility.wayland_sender = Some(tx);
|
||||
}
|
||||
},
|
||||
|
|
@ -1605,8 +1611,10 @@ impl cosmic::Application for App {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn apply_hc_theme(builder: cosmic_theme::ThemeBuilder, enabled: bool) -> Result<cosmic_theme::Theme, cosmic_config::Error> {
|
||||
pub fn apply_hc_theme(
|
||||
builder: cosmic_theme::ThemeBuilder,
|
||||
enabled: bool,
|
||||
) -> Result<cosmic_theme::Theme, cosmic_config::Error> {
|
||||
let is_dark = builder.palette.is_dark();
|
||||
let mut builder = builder.clone();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue