I would like to display the upcoming events list as a standard item on a floating menu.
The AppleScript below works in the "Script Editor," but it causes freezing and lag in BTT (BetterTouchTool). Do anyone have any suggestions for addressing this issue?
-- Define the list of calendars to retrieve events from
set calendarNames to {"Personal", "Becca", "Work", "Friend"}
set todayEvents to {}
-- Get current date information
set currentDate to current date
set todayStart to current date
set todayEnd to current date
-- Set the time of todayStart to midnight
set time of todayStart to 0
-- Set todayEnd to midnight of the next day
set todayEnd to todayStart + 1 * days
-- Tell the Calendar application to fetch events
tell application "Calendar"
repeat with calName in calendarNames
try
set selectedCalendar to calendar calName
set eventList to (every event of selectedCalendar whose start date ≥ todayStart and start date < todayEnd)
repeat with currentEvent in eventList
set eventName to summary of currentEvent
set startTime to start date of currentEvent
set endTime to end date of currentEvent
set eventLocation to location of currentEvent
if eventLocation is missing value or eventLocation = "" then
set eventLocation to "-n/a-"
end if
-- Extract hour and minute for start and end times
set startTimeFormatted to text -8 thru -4 of ((time string of startTime) as string)
set endTimeFormatted to text -8 thru -4 of ((time string of endTime) as string)
-- Format with line breaks and add to the list of today's events
set formattedEvent to eventName & return & startTimeFormatted & " - " & endTimeFormatted & return & eventLocation & return & return
set end of todayEvents to formattedEvent
end repeat
on error
-- Handle case where calendar is not found
end try
end repeat
end tell
-- Return the list of formatted events with line breaks
return todayEvents