Turn GC-BTT notifications off when DND is enabled

I really like the whatsapp/imessage/etc. notifications on the right side in BTT GC, but they're a bit distracting when I am trying to do work. I have DND enabled when I'm working, to turn banners, etc. off, but when I see the iMessage logo I'm very tempted to click it lol.

I have no experience with coding, so I don't know how to add this in the current code of GC, but would you be able to guide me or give me the code to replace the current code that includes a way to disable the iMessage icon from appearing while DND is enabled? If I see how you wrote the iMessage one, I could probably add a similar string to the other notification icons, but iMessage is my most frequently used app that has notifications in BTT so I'd be very interested in something like that.

If it's not too much trouble and you have a way to code this with relative ease, I'd love your help. If this is a complicated request please let me know, I don't want to trouble you with anything complicated so in that case I'd just turn the notifications off altogether, but I thought I'd see if there's a way to integrate DND with notifications before turning them all off.

I love this idea. I’ll look into implementing this behavior!


great to hear! How can we get notified of your updates? Do you notify via twitter or is there a thread that you comment on when there's an update for GC? Or do we just periodically check your release page in presets?

I think an extra invisible widget that sets a simple BTT variable would work well.

I’ll try get it to work at my side, i’ll get back to you if it does!

You can set the GC-BTT release thread to "watched" and the forum will send you emails when new versions are posted. I'm the only one who can post in the release thread so you don't have to worry about getting anything sent to your inbox that isn't a release.

I've been thinking about some kind of built-in "update available" indicator but not sure how to make it. It's on the list of "one day" things haha.

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



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"


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

Thank you so much man you rock!

Just to clarify, I put the listener code at the top in the messages widget, for example, and then add the 2nd part, about DND status, below that? And adding the existing code where you've said to add?

Hi! Sorry for my late reply.

You're meant to add step 1 as a seperate widget. Use the 'paste JSON from clipboard' function.

for step 2: do this for every single notification widget:

Add this above all it's code:

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

then under all it's code add:

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

Here's an example of what one notification widget looks like after the edits:

tell application "BetterTouchTool" to set LCL_DNDStatus to get_string_variable "DNDStatus"
if LCL_DNDStatus is "OFF" then
	if application "Caprine" is running then
		tell application "System Events"
			tell process "Dock"
					set badgeNumber to value of attribute "AXStatusLabel" of UI element "Caprine" of list 1
					if badgeNumber exists 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"
							return badgeNumber
						end if
						return ""
					end if
				on error
					return ""
				end try
			end tell
		end tell
		return ""
	end if
	return ""
end if
1 Like

Awesome work, @yuuiko! I'll implement this in the next version of GC-BTT. :smiley:

1 Like

I've also increased the stability of DND sensing. The code in the DND handler is pretty much the same as the DND widget, but i've added some logic because there was an issue where it wouldn't be able to find the right notification centre toggle. Take a look and compare it with an existing DND widget, then maybe update your DND widgets too.

1 Like

Will do. Oh, this is slightly off-topic, but while I'm catching up on listeners - is there still no way to detect True Tone without calling System Preferences?

I don't think i have a true tone detect-enabled widget on my side. I guess I should add it.

but yeh, i don't have a true tone laptop so it will be hard for me to do this one

I don't have a True Tone Mac either :joy: so I'm basically planning on setting it up and hoping someone with a 2018 MBP will let me know that it works. Lots of people have mentioned that the current True Tone icon doesn't change color so I have a feeling that actually won't be an issue, haha. I have the alternate color already in there, just gotta figure out a way to detect the setting...

1 Like

lol i'll take a look at it, probably last. I have a massive list of feature requests to go through XD
the list:

And i'm implementing BTT alpha's new (buggy) features too.
If you're curious about what i'm doing on the AQT side you can head over to the chat between me and Andreas:

Also working on a skip ad & PiP widget for youtube with @iAmWaldo

I'll get back if i find something.

p.s. wow typing this out made me realise how much i'm doing, haha

1 Like


Just remembered a thing: try “defaults-read” shell scripts. I use these here and there to read BTT’s preferences without opening it, so maybe the true tone value might be somewhere in there.
We don’t have TT macBooks though so the entry might not be returned.

Try in terminal:

defaults read com.apple.systempreferences

It will return all changed preferences. If the preference is not changed then it might not appear, i don’t know how SysPreferences handles the defaults read though so you need to do some experiments there.

Here’s a sample where I use defaults read in a function:

tell application "BetterTouchTool" to set Haptics_Status to get_string_variable "HAPTICS_CurrentlyOn"

if Haptics_Status is "ON" then


set BTTHapticPref to do shell script "defaults read com.hegenberg.BetterTouchTool BTTTouchBarHapticFeedback"

if BTTHapticPref is not 0 then trigger_named "Hold Haptic Style"

on error

trigger_named "Hold Haptic Style"

end try

end if
1 Like

@GoldenChaos and @yuuiko I have a 2018 MacBook Pro with True Tone. I can do the testing for you if need be. Just let me know what you want done and how to verify things are working as you expect.


Hi GC,

I have also noticed the true-tone button doesn't do anything on my 2018 MBP. And to add to this, while the Night Shift icon for your Touch Bar does toggle the night shift on or off, it doesn't toggle the actual night shift button in the Notification Center, versus the DND icon in your Touch Bar, which does toggle the DND icon in the Notification Center.

The issue with this is: because the night shift doesn't toggle native night shift toggle button, if night shift is turned off, and I toggle it on using your Touch Bar icon, the night shift will turn on now, but the Mac's notification centre still thinks night shift is off, and there are times the night shift flickers on and off really fast (I assume there's some sort of issue where the native Notification Center is telling night shift to turn off because it's toggled off, but your Touch Bar button is opposing this)

After experiencing this, I have stopped using your night shift button as it causes the flicker of it being off and on really fast, and resorted to just use the native night shift toggle in the Notification Center and haven't experienced this issue. I hope you can figure out a way to toggle night shift in your Touch Bar button that also toggles native night shift button in the notification center, which is exactly how your DND icon works.

Hope this helps. And in addition to the other user, I also have a 2018 MBP and can help you test features if you need, would just need guidance on what to try and how to report back if you need people to help with that.


the BTT Toggle True Tone predefined action definitely works here (you can see it checking and unchecking the appropriate box in system preferences => display). The effect is sometimes subtle but I can definitely see it. So unless the Goldenchaos preset is using some different mechanism to trigger True Tone, this should be working.

As there is no official API to trigger the default night shift, BTT is changing the params itself, so this won't be reflected in the notification center. This may not really be fixable

Hi All,
Let's move this TrueTone discussion to a new thread.

@6ixStacks, @dugdun, are you still up to help? @GoldenChaos and I don't have true tone MacBooks so we pretty much would be coding blind. It would be great if you could help!

See you over at that thread!

1 Like

@GoldenChaos, @6ixStacks,

Have you tried the code, and does it work well?
I don't get much notifications so I'd like to verify if it's working for you guys.