Battery-triggered Button

You're welcome.
The preset you see there is a newer version of my PHoeNiX Preset. I have to update it, since I made some major changes, but I didn't find the time yet.


Ok the haptic feedback makes it a bit more complicated. You have to go to the Named & Other Triggers section, make a new Reusable Named Trigger (f.eg "Battery Feedback"), and give it the haptic feedback action. With a right click on the Named Trigger, select "Copy Selected Item UUID".

Go back to the widget. The following has to be pasted between the 6th and 7th line of the script I posted above.

	tell application "BetterTouchTool"
		execute_assigned_actions_for_trigger "PASTE_THE_UUID_HERE"
	end tell

The final result should look like that.

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 less than "11" then
    	tell application "BetterTouchTool"
			execute_assigned_actions_for_trigger "PASTE_THE_UUID_HERE"
		end tell
		set remaininghours to word 8 of paragraph 2 of (do shell script "pmset -g batt")
		set remainingminutes to word 9 of paragraph 2 of (do shell script "pmset -g batt")
		return "Warning: " & batteryPercent & "% Remaining. Please charge MacBook." & "
" & remaininghours & "h" & remainingminutes & " 'till Lockdown"
	else
		return ""
	end if
end if

Now set the widget to refresh every 10sec in order to make you trackpad vibrate every 10s.

Et voilĂ . :slightly_smiling_face: That should be what you desire :smiley: