Battery-triggered Button

You have to run it every now and then… :smiley: Something like every 60sec or so should be fine for the battery. Also, do not place this widget inside a group, as the group would prevent running the script for performance and energy reasons as long as the group is not open.

wait so untick 'show in amy open group'?

No, this has to stay. But the widget itself has to remain in the main section, not put inside a folder. "Always display" is perfect.

the red bar is still activating when its not below 10%
coding:

set powersource to word 4 of paragraph 1 of (do shell script "pmset -g batt")
if powersource is "AC" then
	return ""
else
	set batteryPercent to word 6 of paragraph 2 of (do shell script "pmset -g batt")
	if batteryPercent is "100" then
		return ""
	else if batteryPercent is less than "11" then
		tell application "BetterTouchTool"
			execute_assigned_actions_for_trigger "1F9B1FAB-8AA0-4005-B330-FE5E6B8FA6A0"
		end tell
		set remainingminutes to word 9 of paragraph 2 of (do shell script "pmset -g batt")
		say "Warning: " & batteryPercent & "% Remaining. Please charge MacBook. " & remainingminutes & "min until lockdown" using "Alex" with stopping current speech without waiting until completion
		return "Warning: " & batteryPercent & "% Remaining. Please charge MacBook. " & remainingminutes & "min until lockdown"
	else
		return ""
	end if
end if

bump..

I don't know why. You get some text in it too?

My battery went to 10% reading all these replies! :joy:

nope...

Works fine here. Guess you have some strange settings/behaviour in the widget setup itself. But that's not script related.

hmm, weird. it was working while on 10%, but not anything below that (9%, etc)
and also, my Mac is currently on 16% and the red strip without text is coming up on touchbar

Just used your guys' long ass conversation to implement this warning to my own Touch Bar. Thanks so much to you to for working this through!

2 Likes

its working for you? dang. lol