Describe the bug
I’m using code like these to check if Slack/Mail has unread every 2s and show alternative menubar icons.
if application "Slack" is running then
tell application "BetterTouchTool"
set badgeNumber to get_dock_badge_for "Slack" update_interval 1
end tell
if badgeNumber is not missing value then
return "unread"
end if
end if
return "read"
it works well initially, unread/read changes as app state changes. However, after a while it just stops updating. e.g. the current screenshot of dock:
but script for Slack and Mail returns read and unread
Now if I restart BTT, everything works as expected again.
I've come up with a workaround using dock-badge-counter. The Homebrew install wasn't working for me, so it may be necessary to compile the release version following instructions in the repo, then mv .build/release/dock-badge-counter /usr/local/bin/dock-badge-counter.
dock-badge-counter path
If installed via Homebrew, edit the DOCK_BADGE_COUNTER_PATH variable (it's currently set for manual install to /usr/local/bin):
Adding new apps
Each new app requires its own function within the shared external JavaScript file since (as far as I can tell) BTT doesn't currently allow passing parameters to scripts.
async function getBadgeCount_Messages() {
return await getBadgeCount("Messages");
}
Badge refresh timing
Feel free to adjust CACHE_TIME_SEC in the script along with the Execute script every # seconds setting on the preset to your desired thresholds.