@GoldenChaos@yuuiko
Next alpha later today will have a new apple script function that can be used like this:
tell application "BetterTouchTool"
get_dock_badge_for "Calendar" update_interval 5
end tell
When an update interval is provided, BTT will internally refresh the badges for all apps every x seconds. In this case the "get_dock_badge_for" function calls are basically free, as they will just return the last cached value. This is the recommended way to do it, and the update_interval should not be too small.
If you need to refresh the cache immediately for some reason, you can leave the update_interval function out. Then BTT will immediately refresh all the dock badges and return the latest value.
tell application "BetterTouchTool"
get_dock_badge_for "Calendar"
end tell
Instead of the app name you can also use its url (to make it independent from any language), e.g. file:///Applications/Google%20Chrome.app/
Giving this a shot now! Expecting to release a new experimental version today with this + dnd detection updates + the initialization fix for the settings menu.
EDIT: Alright, this is fully implemented in 2.814!!
@Andreas_Hegenberg seeing a potential issue with the badge numbers updating. I got a text and the badge number for Messages returned 1, but after reading the message the number variable continues to return 1, meaning the dock badge never disappears. Restarting BTT fixes the variable discrepancy. Seems like the number is just failing to update itself.
did you provide an update interval? you still need to execute the script every time you want a new value - the update interval just updates the internal btt variable, your script needs to still retrieve it in regular intervals. This means your script won't take cpu, but it still needs to run
Yup - here's the new script for a dock badge, which itself runs every 5s:
tell application "BetterTouchTool"
try
set dndEnabled to get_number_variable "SystemDoNotDisturbState"
end try
end tell
if dndEnabled is 0 then
tell application "BetterTouchTool"
set badgeNumber to get_dock_badge_for "Google Chrome Canary" update_interval 5
end tell
if badgeNumber is not missing value then
if badgeNumber contains "iPhone" then
return "iPhone"
else if badgeNumber contains "iPad" then
return "iPad"
else if badgeNumber contains "watch" then
return "Watch"
else if badgeNumber contains "Mac" then
return "Mac"
else
return badgeNumber
end if
else
return ""
end if
else
return ""
end if
It seems to specifically happen when the dock badge value changes to missing value, if that helps. BTT doesn't seem to be able to cope with going from having a badge to not having one. Updating from one value to another, however, works properly.