Turn GC-BTT notifications off when DND is enabled

I've got this working, though i still need to paste it into every widget.

@GoldenChaos:

1

I made a listener widget that never shows itself but is active in the background.

Insert it with the Notification Widgets.
Here's it's JSON:

Show widget "DND Handler"
{
  "BTTWidgetName" : "DND Handler",
  "BTTTriggerType" : 639,
  "BTTTriggerTypeDescription" : "Apple Script Widget",
  "BTTTriggerClass" : "BTTTriggerTypeTouchBar",
  "BTTPredefinedActionType" : -1,
  "BTTPredefinedActionName" : "No Action",
  "BTTEnabled2" : 1,
  "BTTUUID" : "48B1CC23-2608-441F-87F5-546B5F8A4246",
  "BTTEnabled" : 1,
  "BTTOrder" : 41,
  "BTTTriggerConfig" : {
    "BTTScriptType" : 0,
    "BTTTouchBarButtonColor" : "32.000000, 32.000000, 32.000000, 255.000000",
    "BTTTouchBarItemIconWidth" : 22,
    "BTTTouchBarItemPlacement" : 2,
    "BTTTouchBarAlternateBackgroundColor" : "32.000000, 32.000000, 32.000000, 255.000000",
    "BTTTouchBarButtonCornerRadius" : 15,
    "BTTTouchBarFontColor" : "63.750000, 63.750000, 63.750000, 255.000000",
    "BTTTouchBarScriptUpdateInterval" : 5,
    "BTTTouchBarAppleScriptString" : "\r--This widget alerts the notification badges to stop showing if Do Not Disturb is on.\r--It never shows itself, it works in the background.\r\rtell application \"System Events\"\r\ttell application process \"SystemUIServer\"\r\t\ttry\r\t\t\tif exists menu bar item \"Notification Center, Do Not Disturb enabled\" of menu bar 1 then\r\t\t\t\ttell application \"BetterTouchTool\" to set_persistent_string_variable \"DNDStatus\" to \"ON\"\r\t\t\t\treturn \"\"\r\t\t\t\t--return \"True1\"\r\t\t\t\t\r\t\t\telse\r\t\t\t\tif exists menu bar item \"Notification Centre\" of menu bar 1 then\r\t\t\t\t\ttell application \"BetterTouchTool\" to set_persistent_string_variable \"DNDStatus\" to \"OFF\"\r\t\t\t\t\treturn \"\"\r\t\t\t\t\t--return \"False\"\r\t\t\t\telse\r\t\t\t\t\ttell application \"BetterTouchTool\" to set_persistent_string_variable \"DNDStatus\" to \"ON\"\r\t\t\t\t\treturn \"\"\r\t\t\t\t\t--return \"True2\"\r\t\t\t\tend if\r\t\t\tend if\r\t\ton error\r\t\t\treturn \"\"\r\t\tend try\r\tend tell\r\t(*\r\ttell application \"BetterTouchTool\"\r\t\tset LCL_DNDStatus to get_string_variable \"DNDStatus\"\r\t\treturn LCL_DNDStatus\r\tend tell\n\t*)\rend tell",
    "BTTTouchBarAppleScriptStringRunOnInit" : true,
    "BTTTouchBarButtonName" : "DND Handler",
    "BTTTouchBarAppleScriptUsePath" : 0,
    "BTTTouchBarFreeSpaceAfterButton" : 5,
    "BTTTouchBarItemIconHeight" : 22,
    "BTTTouchBarItemPadding" : 0,
    "BTTTouchBarFontColorAlternate" : "63.750000, 63.750000, 63.750000, 255.000000"
  }
}

2

Wrap all the code in each notification widget with:

tell application "BetterTouchTool" to set this_DNDStatus to get_string_variable "DNDStatus"
if this_DNDStatus is "OFF" then

-- Existing Widget Code here --

else --if DND is ON, prevent show badge.
    return ""
end if

Hope that's helpful!

1 Like