A timer widget for the touch bar
I made a simple timer widget for the touch bar that actually consists of just one widget. When pressed, It asks for the time via a dialog popup and starts the countdown. If pressed again, it cancels the countdown. When finished, it blinks red/black a few times. The widget only refreshes regularly while the timer is actually running, so the power usage should be really low i think.
feel free to leave feedback!
download link:
https://share.folivora.ai/sharedPreset/53545d61-1a3a-4f54-ae6f-e2954cec4ff9
Note that in order for the widget to work I think you have to copy the UUID of the widget by right clicking on it and replace the UUID in the script (it appears several times).
I'm not sure whether importing the widget from the download works, see the comments. Alternatively, create a widget on your own and paste the scripts below. I would suggest then setting 255,38,0 as alternative background color activating when the return value is "00:00", so the widget stays red after blinking when the time is up. Also you can set the "Execute every X seconds" value much higher than default, as the widget gets refreshed by the script when necessary. I used the "Alarm" icon from this icon pack: [v3 Update] Native Apple Touch Bar Icon Pack for BTT
Widget JSON:
{
"BTTWidgetName" : "Timer",
"BTTTriggerType" : 639,
"BTTTriggerTypeDescription" : "Apple Script Widget",
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : 195,
"BTTPredefinedActionName" : "Apple Script starten (asynchron im Hintergrund)",
"BTTInlineAppleScript" : "tell application \"BetterTouchTool\"\r\t\r\tset remainingSeconds to get_number_variable \"remainingSeconds\"\r\t\r\tif (remainingSeconds is equal to 99999) or (remainingSeconds is equal to missing value) then --timer is not running and should be started\r\t\t\r\t\t--ask for the duration via a dialog popup\r\t\tset dialogAnswer to display dialog \"Please set timer using HH:MM:SS (max. 24 hours):\" default answer \"00:00:05\" --edit this to change the default time\r\t\tset answer to text returned of dialogAnswer\r\t\tset answerHours to text 1 thru 2 of answer as text\r\t\tset answerMinutes to text 4 thru 5 of answer as text\r\t\tset answerSeconds to text 7 thru 8 of answer as text\r\t\t\r\t\tset totalSeconds to (answerHours * 3600) + (answerMinutes * 60) + answerSeconds\r\t\t\r\t\tset_number_variable \"remainingSeconds\" to 99998\r\t\t\r\t\trepeat totalSeconds times --count\r\t\t\tif (get_number_variable \"remainingSeconds\") ≠ 99999 then -- if the variable is 99999, that means the timer was pressed again and should be stopped\r\t\t\t\tset totalSeconds to (totalSeconds - 1)\r\t\t\t\tset_number_variable \"remainingSeconds\" to totalSeconds\r\t\t\t\trefresh_widget \"2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10\"\r\t\t\t\tdelay 1\r\t\t\tend if\r\t\tend repeat\r\t\t\r\t\tif (get_number_variable \"remainingSeconds\") ≠ 99999 then\r\t\t\trepeat 10 times --blink to signal that the time is up\r\t\t\t\tupdate_touch_bar_widget \"2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10\" background_color \"0,0,0,0\"\r\t\t\t\tdelay 0.5\r\t\t\t\tupdate_touch_bar_widget \"2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10\" background_color \"255,38,0,255\"\r\t\t\t\tdelay 0.5\r\t\t\tend repeat\r\t\tend if\r\t\t\r\telse --timer is running and should be stopped\r\t\tset_number_variable \"remainingSeconds\" to 99999\r\t\trefresh_widget \"2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10\"\r\tend if\r\t\rend tell",
"BTTEnabled2" : 1,
"BTTUUID" : "2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10",
"BTTEnabled" : 1,
"BTTModifierMode" : 0,
"BTTOrder" : 91,
"BTTDisplayOrder" : 0,
"BTTMergeIntoTouchBarGroups" : 0,
"BTTIconData" : "TU0AKgAAE7gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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323769, 75.323769, 255.000000",
"BTTTouchBarColorRegex" : "00:00",
"BTTTouchBarItemIconWidth" : 30,
"BTTTouchBarItemPlacement" : 0,
"BTTTouchBarAlternateBackgroundColor" : "255.000000, 38.028511, 0.000000, 255.000000",
"BTTTouchBarButtonCornerRadius" : 6,
"BTTTouchBarScriptUpdateInterval" : 60,
"BTTTouchBarAppleScriptString" : "tell application \"BetterTouchTool\"\r\tset remainingSeconds to get_number_variable \"remainingSeconds\"\r\t\r\tif (remainingSeconds is equal to 99999) or (remainingSeconds is equal to missing value) then -- the timer is not running\r\t\treturn \"timer\"\r\telse -- the timer is running or is finished\r\t\t\r\t\t--create return text\r\t\tset outputSeconds to ((remainingSeconds mod 3600) mod 60) as integer\r\t\tset outputMinutes to (((remainingSeconds - outputSeconds) mod 3600) \/ 60) as integer\r\t\tset outputHours to ((remainingSeconds - outputMinutes * 60 - outputSeconds) \/ 3600) as integer\r\t\tif length of (outputSeconds as string) is equal to 1 then\r\t\t\tset outputSeconds to \"0\" & outputSeconds as string\r\t\tend if\r\t\tif length of (outputMinutes as string) is equal to 1 then\r\t\t\tset outputMinutes to \"0\" & outputMinutes as string\r\t\tend if\r\t\t\r\t\t--return text\r\t\tif outputHours is greater than 0 then\r\t\t\treturn (outputHours & \":\" & outputMinutes & \":\" & outputSeconds) as string\r\t\telse\r\t\t\treturn (outputMinutes & \":\" & outputSeconds) as string\r\t\tend if\r\tend if\rend tell",
"BTTTouchBarAppleScriptStringRunOnInit" : false,
"BTTTouchBarButtonName" : "Timer",
"BTTTouchBarAppleScriptUsePath" : 0,
"BTTTouchBarFreeSpaceAfterButton" : 5,
"BTTTouchBarItemIconHeight" : 30,
"BTTTouchBarItemPadding" : 0
}
}
the script for the return value:
tell application "BetterTouchTool"
set remainingSeconds to get_number_variable "remainingSeconds"
if (remainingSeconds is equal to 99999) or (remainingSeconds is equal to missing value) then -- the timer is not running
return "timer"
else -- the timer is running or is finished
--create return text
set outputSeconds to ((remainingSeconds mod 3600) mod 60) as integer
set outputMinutes to (((remainingSeconds - outputSeconds) mod 3600) / 60) as integer
set outputHours to ((remainingSeconds - outputMinutes * 60 - outputSeconds) / 3600) as integer
if length of (outputSeconds as string) is equal to 1 then
set outputSeconds to "0" & outputSeconds as string
end if
if length of (outputMinutes as string) is equal to 1 then
set outputMinutes to "0" & outputMinutes as string
end if
--return text
if outputHours is greater than 0 then
return (outputHours & ":" & outputMinutes & ":" & outputSeconds) as string
else
return (outputMinutes & ":" & outputSeconds) as string
end if
end if
end tell
the script that is executed when the widget is pressed:
tell application "BetterTouchTool"
set remainingSeconds to get_number_variable "remainingSeconds"
if (remainingSeconds is equal to 99999) or (remainingSeconds is equal to missing value) then --timer is not running and should be started
--ask for the duration via a dialog popup
set dialogAnswer to display dialog "Please set timer using HH:MM:SS (max. 24 hours):" default answer "00:00:05" --edit this to change the default time
set answer to text returned of dialogAnswer
set answerHours to text 1 thru 2 of answer as text
set answerMinutes to text 4 thru 5 of answer as text
set answerSeconds to text 7 thru 8 of answer as text
set totalSeconds to (answerHours * 3600) + (answerMinutes * 60) + answerSeconds
set_number_variable "remainingSeconds" to 99998
repeat totalSeconds times --count
if (get_number_variable "remainingSeconds") ≠ 99999 then -- if the variable is 99999, that means the timer was pressed again and should be stopped
set totalSeconds to (totalSeconds - 1)
set_number_variable "remainingSeconds" to totalSeconds
refresh_widget "2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10"
delay 1
end if
end repeat
if (get_number_variable "remainingSeconds") ≠ 99999 then
repeat 10 times --blink to signal that the time is up
update_touch_bar_widget "2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10" background_color "0,0,0,0"
delay 0.5
update_touch_bar_widget "2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10" background_color "255,38,0,255"
delay 0.5
end repeat
end if
else --timer is running and should be stopped
set_number_variable "remainingSeconds" to 99999
refresh_widget "2CA20DFA-8DAC-4E9A-A095-8BCC75ABAD10"
end if
end tell