Personally I don't mind making a bunch of badges for every app, though being able to create and remove "virtual" buttons on-the-fly is something I've wanted for a while and would make the reminders/calendar/browser tabs groups behave a lot nicer. I might make a separate thread to request this feature, I know it's come up in the past and add_new_trigger
isn't a good option for this because it creates permanent buttons.
@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/
Hope this works!!
Will these have a “don’t show when DND ON” function?
Otherwise a dnd variable would be great. A couple of my users are struggling with the badges always hiding and i’m not sure what’s causing it
The function just returns the current dock badge number for the requested app efficiently, what you do with it is up to you
Ok, just added a variable for that. It's available via "SystemDoNotDisturbState" as a number variable.
how does it sense dnd? just curious
It reads the user defaults of the notificationcenterui
NSUserDefaults* defaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.apple.notificationcenterui"];
BOOL dnd = [defaults boolForKey:@"doNotDisturb"];
shoot wait
could I have just used defaults read then? aha well it’s coming
Not sure if a normal read would work because it may not access the "live state", but yeah probably it would
Oh another thing, what does the new badge function return? The same as now right?
Especially for handoff. Just wondering if I need to rewrite the display rules of the widget or they can stay as is
In addition I think the docs need an update too
It just returns the current/last cached dock badge as a string.
So e.g. "2" or "lalala"
I'll do a big docs update next week that is based on the new UI and everything
It's now integrated in v2.814 alpha
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
I will try it later when I'm back at home. Maybe there is still some bug that prevents the update
Your code looks good.
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.
ah thanks for finding that! I forgot to delete them
Will upload a new build in a few minutes.