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