From 7000e2f946ff9ba51fc3631825cf4c17ae064232 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 28 Nov 2025 13:13:04 +0000 Subject: darwin: better way of getting app badge --- lib/doc/jao-mac.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/doc') diff --git a/lib/doc/jao-mac.el b/lib/doc/jao-mac.el index ad11ea2..eca5d9a 100644 --- a/lib/doc/jao-mac.el +++ b/lib/doc/jao-mac.el @@ -81,6 +81,13 @@ (format "display notification %S with title %S subtitle %S" msg title subtitle))) +(defun jao-mac-app-badge (app) + "A very hacky, yet efficient, way of getting and apps badge." + (let* ((c (format "lsappinfo info -app %s -only StatusLabel" app)) + (s (shell-command-to-string c))) + (when (string-match ".*=\"\\([0-9]+\\)\" ." s) + (string-to-number (match-string 1 s)))) ) + ;;; Skim (defvar jao-skim--current-file-script (jao-mac-applescript-prepare @@ -156,10 +163,7 @@ "lsappinfo info -app NetNewsWire -only StatusLabel") (defun jao-nnw-unread-count () - "A very hacky, yet efficient, way of getting NNW's badge." - (let ((s (shell-command-to-string jao-nnw--label-cmd))) - (when (string-match ".*=\"\\([0-9]+\\)\" ." s) - (string-to-number (match-string 1 s))))) + (jao-mac-app-badge "NetNewsWire")) (defun jao-mac-open-nnw () (interactive) -- cgit v1.2.3