when I press run script, it works, but when the battery reaches the set percentage (set to 16% for testing) it didn't come up.
[
{
"BTTWidgetName" : "battery",
"BTTTriggerType" : 639,
"BTTTriggerTypeDescription" : "Apple Script / JavaScript Widget",
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : -1,
"BTTPredefinedActionName" : "No Action",
"BTTEnabled2" : 1,
"BTTRepeatDelay" : 0,
"BTTUUID" : "A3C99C29-EFC8-42C4-8B44-E569DAFBEEAA",
"BTTNotesInsteadOfDescription" : 0,
"BTTEnabled" : 1,
"BTTModifierMode" : 0,
"BTTOrder" : 39,
"BTTDisplayOrder" : 0,
"BTTMergeIntoTouchBarGroups" : 0,
"BTTTriggerConfig" : {
"BTTTouchBarAppleScriptString" : "set powersource to word 4 of paragraph 1 of (do shell script "pmset -g batt")\rif powersource is "AC" then\r\treturn ""\relse\r\tset batteryPercent to word 6 of paragraph 2 of (do shell script "pmset -g batt")\r\tif batteryPercent is "100" then\r\t\treturn ""\r\telse if batteryPercent is less than "17" then\r\t\tset remainingminutes to word 9 of paragraph 2 of (do shell script "pmset -g batt")\r\t\tset buttonSet to {"OK"}\r\t\t\r\t\tdisplay alert "Warning." message "Battery is " & batteryPercent & "%. Please charge your Macbook." buttons buttonSet as critical\r\t\t\r\telse\r\t\treturn ""\r\tend if\rend if",
"BTTTouchBarButtonColor" : "75.323769, 75.323769, 75.323769, 255.000000",
"BTTTouchBarItemPlacement" : 0,
"BTTTouchBarAppleScriptStringRunOnInit" : 1,
"BTTTouchBarAlwaysShowButton" : false,
"BTTScriptType" : 0,
"BTTTouchBarScriptUpdateInterval" : 0.10000000149011612,
"BTTTouchBarButtonWidth" : 100,
"BTTTouchBarItemIconHeight" : 22,
"BTTTouchBarButtonTextAlignment" : 0,
"BTTTouchBarAlternateBackgroundColor" : "75.323769, 75.323769, 75.323769, 255.000000",
"BTTTouchBarAppleScriptUsePath" : 0,
"BTTTBWidgetWidth" : 400,
"BTTTouchBarItemIconWidth" : 22,
"BTTTouchBarButtonName" : "battery",
"BTTTouchBarButtonFontSize" : 15,
"BTTTouchBarIconTextOffset" : 5,
"BTTTouchBarOnlyShowIcon" : false,
"BTTTouchBarFreeSpaceAfterButton" : 5,
"BTTTouchBarItemPadding" : 0
}
}
]