@@ -37,7 +37,7 @@ function Screen() {
{({ isActive }) => (
diff --git a/src-tauri/src/commands/window.rs b/src-tauri/src/commands/window.rs
index 4ee154b7..6167a5e2 100644
--- a/src-tauri/src/commands/window.rs
+++ b/src-tauri/src/commands/window.rs
@@ -1,3 +1,5 @@
+#[cfg(target_os = "macos")]
+use cocoa::{appkit::NSApp, base::nil, foundation::NSString};
use std::path::PathBuf;
use tauri::utils::config::WindowEffectsConfig;
use tauri::window::Effect;
@@ -166,3 +168,17 @@ pub fn open_window(
Ok(())
}
+
+#[tauri::command]
+pub fn set_badge(count: i32) {
+ #[cfg(target_os = "macos")]
+ unsafe {
+ let label = if count == 0 {
+ nil
+ } else {
+ NSString::alloc(nil).init_str(&format!("{}", count))
+ };
+ let dock_tile: cocoa::base::id = msg_send![NSApp(), dockTile];
+ let _: cocoa::base::id = msg_send![dock_tile, setBadgeLabel: label];
+ }
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index e9b4315b..7537439a 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -138,7 +138,8 @@ fn main() {
commands::window::resize_column,
commands::window::open_window,
commands::window::get_path,
- commands::window::navigate
+ commands::window::navigate,
+ commands::window::set_badge
])
.run(tauri::generate_context!())
.expect("error while running tauri application")