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.
Sorry I'm not sure I understand, could you post a screenshot of the Dock in this case?
(I'm not using handoff, not sure how that looks like).
Do you have the accessibility inspector app installed? That could show some additional info.
Instead of using the app name you can already use the URL of the dock item to get t he value:
'iPhone'
'iPad'
'watch'
'Mac'
a Notification Number.
In this situation (Handoff available, but have '1' badge):
The variable returns 1, overriding the handoff 'iPhone'. Normally if there is no badge it'll return details about the connected device, but because there is a notification, that is overrided with a 1.
With my code below, this means that the widget won't show up for handoff.
Code:
tell application "BetterTouchTool" to set LCL_DNDStatus to get_string_variable "DNDStatus"
if LCL_DNDStatus is "OFF" then
tell application "BetterTouchTool" to set badgeNumber to get_dock_badge_for "Reminders" update_interval 5
if badgeNumber is not missing value then
if badgeNumber contains "iPhone" then
return "{\"text\":\"π±\",\"font_size\": 15}"
else if badgeNumber contains "iPad" then
return "{\"text\":\"β¬οΈ\",\"font_size\": 15}"
else if badgeNumber contains "watch" then
return "{\"text\":\"βοΈ\",\"font_size\": 15}"
else if badgeNumber contains "Mac" then
return "{\"text\":\"π₯\",\"font_size\": 15}"
else if application "Reminders" is running then
return "{\"text\":\"" & badgeNumber & "\",\"font_size\": 15}"
else
return ""
end if
else
return ""
end if
else
return ""
end if
Ah I see. I don't think overriding the number value would be ideal as it would prevent various usecases. I'll just add a -handoff to the application name/url for these items.
tell application "BetterTouchTool" to set LCL_DNDStatus to get_string_variable "DNDStatus"
if LCL_DNDStatus is "OFF" then
tell application "BetterTouchTool"
set badgeNumber to get_dock_badge_for "News" update_interval 3
set handoffDevice to get_dock_badge_for "News-handoff" update_interval 3
end tell
if badgeNumber is not missing value and handoffDevice is missing value then
if application "News" is running then
return "{\"text\":\"" & badgeNumber & "\",\"font_size\": 15}"
else
return ""
end if
else if handoffDevice is not missing value then
if handoffDevice contains "iPhone" then
return "{\"text\":\"π±\",\"font_size\": 15}"
else if handoffDevice contains "iPad" then
return "{\"text\":\"β¬οΈ\",\"font_size\": 15}"
else if handoffDevice contains "watch" then
return "{\"text\":\"βοΈ\",\"font_size\": 15}"
else if handoffDevice contains "Mac" then
return "{\"text\":\"π₯\",\"font_size\": 15}"
end if
else
return ""
end if
else
return ""
end if