diff options
| author | jao <jao@gnu.org> | 2025-11-28 13:13:04 +0000 |
|---|---|---|
| committer | jao <jao@gnu.org> | 2025-11-28 13:13:04 +0000 |
| commit | 7000e2f946ff9ba51fc3631825cf4c17ae064232 (patch) | |
| tree | e87fcf68b9dbffa35f9d3b6aa53fa323487e0d07 | |
| parent | 6582785a4004fe68c79219c690aaafdc8ec5a240 (diff) | |
| download | elibs-7000e2f946ff9ba51fc3631825cf4c17ae064232.tar.gz elibs-7000e2f946ff9ba51fc3631825cf4c17ae064232.tar.bz2 | |
darwin: better way of getting app badge
| -rw-r--r-- | custom/jao-custom-notmuch.el | 9 | ||||
| -rw-r--r-- | lib/doc/jao-mac.el | 12 |
2 files changed, 15 insertions, 6 deletions
diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el index e093ed4..89bd217 100644 --- a/custom/jao-custom-notmuch.el +++ b/custom/jao-custom-notmuch.el @@ -26,6 +26,8 @@ (defsubst jao-notmuch--qstr (c) (format "%s%s" (plist-get c :name) (plist-get c :count))) +(defvar jao-notmuch-mac-xbar t) + (defun jao-notmuch-xbar () (let ((cnts (notmuch-hello-query-counts jao-notmuch-xbar-queries))) (jao-shell-exec (format "echo '%s | color=#8b3626 | size=11' >/tmp/xbar" @@ -33,7 +35,10 @@ (defun jao-notmuch-notify () (interactive) - (let ((cnts (notmuch-hello-query-counts jao-notmuch-minibuffer-queries))) + (let* ((cnts (notmuch-hello-query-counts jao-notmuch-minibuffer-queries)) + (mc (jao-d-l + (unless jao-notmuch-mac-xbar (jao-mac-app-badge "Mail")) 0)) + (cnts (if (> (or mc 0) 0) (cons `(:name "" :count ,mc) cnts) cnts))) (setq jao-notmuch-minibuffer-string (mapconcat (lambda (c) (propertize (jao-notmuch--qstr c) @@ -41,7 +46,7 @@ 'jao-themes-dimm))) cnts " ")) - (jao-when-darwin (jao-notmuch-xbar)) + (jao-when-darwin (when jao-notmuch-mac-xbar (jao-notmuch-xbar))) (jao-minibuffer-refresh))) (defun jao-notmuch-notify-and-update () 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) |
