feat: watch linux theme changed (#7781)

* feat: add Linux theme change notifications and update dark-light dependency

* fix: remove unused tauri Emitter import

* update changelog

* fix: clippy

* fix: pnpm format
This commit is contained in:
oomeow
2026-08-20 16:09:16 +00:00
committed by GitHub
parent 332097bc9f
commit e71cf0ec68
6 changed files with 97 additions and 40 deletions
+26
View File
@@ -40,6 +40,8 @@ pub fn resolve_setup_sync() {
AsyncHandler::spawn(|| async {
AsyncHandler::spawn_blocking(init_scheme);
AsyncHandler::spawn_blocking(init_embed_server);
#[cfg(target_os = "linux")]
AsyncHandler::spawn_blocking(watch_linux_theme_changed);
});
}
@@ -111,6 +113,30 @@ pub(super) fn init_embed_server() {
server::embed_server();
}
#[cfg(target_os = "linux")]
pub(crate) fn watch_linux_theme_changed() {
match dark_light::subscribe() {
Ok(watcher) => {
for mode in watcher.iter() {
use crate::core::notification;
let theme = match mode {
dark_light::Mode::Light => tauri::Theme::Light,
dark_light::Mode::Dark => tauri::Theme::Dark,
dark_light::Mode::Unspecified => tauri::Theme::Light, // fallback to light
};
notification::NotificationSystem::send_event(
Handle::app_handle().clone(),
notification::FrontendEvent::ThemeChanged { theme },
);
}
}
Err(e) => {
logging_error!(Type::Setup, "Fail to watch linux theme changed: {}", e);
}
}
}
pub(super) async fn init_resources() {
logging_error!(Type::Setup, init::init_resources().await);
}