Fixed it.
After I put the old data files in place and got it back to a useable state, I turned OFF TouchBar support in the general settings. That meant I could put the original data files back, without it running the code on startup. That gave me the chance to edit out the offending code, and now it's back to where it was earlier today, before I added the racing code (which, I think, is associated with using get_string_variable).
I have this code (which works fine):
set upcomingEvents to do shell script "/usr/local/bin/icalbuddy -n -nc -nrd -ps "| - |" -iep "title,datetime" -po "datetime,title" -df "%a" -ic "Todoist" -eed eventsToday+7"
if (length of upcomingEvents) > 0 then
set maxSize to 49
set trailing to ""
set nextevent to first paragraph of upcomingEvents
set l to length of nextevent
if l > maxSize + 2 then
l = maxSize + 2
trailing = "…"
end if
set nextevent to (text 3 thru l of nextevent) & trailing
else
set nextevent to "No tasks"
end if
return nextevent
I moved the "do shell script" statement into a named trigger:
set upcomingEvents to do shell script "/usr/local/bin/icalbuddy -n -nc -nrd -ps "| - |" -iep "title,datetime" -po "datetime,title" -df "%a" -ic "Todoist" -eed eventsToday+7"
tell application "BetterTouchTool" to set_string_variable "BTT_TODOIST_TASKS" to upcomingEvents
and replaced that line with:
tell application "BetterTouchTool"
trigger_named "get-todoist-tasks"
try
set upcomingEvents to get_string_variable "BTT_TODOIST_TASKS"
on error
set upcomingEvents to ""
end try
end tell
BTT stops responding with this code in place. The named trigger seems to run fine, so I think the problem is in the trigger_named or the get_string_variable (I think it's this one, because I'm sure I've had problems with it in the past).
Anyway, time to save everything out to JSON files before I bugger up anything else...