Skip to content

Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.

Show the unread badge on the Dock icon

VRonGitHub358e0664d5e8
diff --git a/apps/rustcord/src/app.rs b/apps/rustcord/src/app.rs
index 4181741..6c01cef 100644
--- a/apps/rustcord/src/app.rs
+++ b/apps/rustcord/src/app.rs
@@ -3038,11 +3038,13 @@ impl RustCord {
crate::tray::notify(&title, &body);
}
- /// The taskbar button's badge (Settings → Notifications → Badges): your
- /// mentions and DMs counted, else a dot for unread messages. Looked at
- /// once a second.
+ /// The taskbar button's badge, or the Dock icon's on macOS (Settings →
+ /// Notifications → Badges): your mentions and DMs counted, else a dot for
+ /// unread messages. Looked at once a second.
fn update_badge(&mut self) {
- if self.hwnd == 0 || self.badge_at.is_some_and(|t| t.elapsed() < Duration::from_secs(1)) {
+ // (Windows needs the window's handle for it; the Dock doesn't.)
+ let window_known = self.hwnd != 0 || cfg!(target_os = "macos");
+ if !window_known || self.badge_at.is_some_and(|t| t.elapsed() < Duration::from_secs(1)) {
return;
}
self.badge_at = Some(Instant::now());