Open james-rose opened 3 years ago
Same behaviour on mbp 16', Big Sur 11.2.3 with the same code snippet.
Same behavior on mbp 16', Big Sur 11.2.3 with the same code snippet.
Same behavior on mbp 13", Mojave with the same code snippet
Here too with Big Sur 11.2.3
Not working on Big Sur 11.5.1
any update?
Same for M1, Monterey 12.4
Not working for MacBook pro 13" M1 2020; macOS Ventura 13.0 FVFGL6Y8Q05N
Not working for MacBook pro 13" Intel 2019; macOS Catalina 10.15.7 (19H2026). May I know why? Should I set something in Calendar?
Here's a kind of solution for this with AppleScript:
{
"type": "appleScriptTitledButton",
"align": "right",
"bordered": true,
"autoResize": true,
"source": {
"inline": "tell application \"Reminders\"\n\tset reminderLists to every list\n\tif (count of reminderLists) > 0 then\n\t\tset firstList to item 1 of reminderLists\n\t\tif (count of reminders in firstList) > 0 then\n\t\t\tset firstReminder to item 1 of reminders in firstList\n\t\t\t\n\t\t\treturn {name of firstReminder, \"\"}\n\t\telse\n\t\t\treturn {\"The first list is empty\", \"\"}\n\t\tend if\n\telse\n\t\t\treturn {\"No lists found\", \"\"}\n\tend if\nend tell"
},
"refreshInterval": 3600, // in seconds
"longAction": "appleScript",
"longActionAppleScript": {
"inline": "activate application \"Reminders\""
}
},
You can change the number of list or item in set firstList to item 1 of reminderLists
set firstReminder to item 1 of reminders in firstList
.
To get the itemLeft
to itemRight
in the listNumber
from "Reminders", use below script to get "title" and embed it into your MTMR json:
on get_reminders(listNumber, itemLeft, itemRight)
tell application "Reminders"
set reminderLists to every list
if (count of reminderLists) > 0 then
set listToGet to item listNumber of reminderLists
set remindersToGet to items itemLeft thru itemRight of reminders in listToGet
set reminderNames to {}
repeat with thisReminder in remindersToGet
set end of reminderNames to name of thisReminder
end repeat
return reminderNames
else
return "There are no reminders"
end if
end tell
end get_reminders
To get the first upcoming event within 3 days in the Calendar (return title and remaining hours):
{
"type": "appleScriptTitledButton",
"align": "right",
"bordered": true,
"autoResize": true,
"source": {
"inline": "tell application \"Calendar\"\n\tset today to current date\n\tset futureDate to today + (3 * days)\n\tset upcomingEvents to every event of calendar 1 whose start date is greater than or equal to today and start date is less than or equal to futureDate\n\tif upcomingEvents is {} then\n\t\treturn \"\"\n\telse\n\t\tset firstEvent to item 1 of upcomingEvents\n\t\tset eventTitle to summary of firstEvent\n\t\tset remainingTime to ((start date of firstEvent) - (current date)) div hours\n\t\treturn eventTitle & remainingTime & \"H\"\n\tend if\nend tell"
},
"refreshInterval": 3600, // in seconds
"longAction": "appleScript",
"longActionAppleScript": {
"inline": "activate application \"Calendar\""
}
},
To get the first upcoming event within 3 days in the Calendar (return title and remaining hours):
{ "type": "appleScriptTitledButton", "align": "right", "bordered": true, "autoResize": true, "source": { "inline": "tell application \"Calendar\"\n\tset today to current date\n\tset futureDate to today + (3 * days)\n\tset upcomingEvents to every event of calendar 1 whose start date is greater than or equal to today and start date is less than or equal to futureDate\n\tif upcomingEvents is {} then\n\t\treturn \"\"\n\telse\n\t\tset firstEvent to item 1 of upcomingEvents\n\t\tset eventTitle to summary of firstEvent\n\t\tset remainingTime to ((start date of firstEvent) - (current date)) div hours\n\t\treturn eventTitle & remainingTime & \"H\"\n\tend if\nend tell" }, "refreshInterval": 3600, // in seconds "longAction": "appleScript", "longActionAppleScript": { "inline": "activate application \"Calendar\"" } },
is it still working? :/
To get the first upcoming event within 3 days in the Calendar (return title and remaining hours):
{ "type": "appleScriptTitledButton", "align": "right", "bordered": true, "autoResize": true, "source": { "inline": "tell application \"Calendar\"\n\tset today to current date\n\tset futureDate to today + (3 * days)\n\tset upcomingEvents to every event of calendar 1 whose start date is greater than or equal to today and start date is less than or equal to futureDate\n\tif upcomingEvents is {} then\n\t\treturn \"\"\n\telse\n\t\tset firstEvent to item 1 of upcomingEvents\n\t\tset eventTitle to summary of firstEvent\n\t\tset remainingTime to ((start date of firstEvent) - (current date)) div hours\n\t\treturn eventTitle & remainingTime & \"H\"\n\tend if\nend tell" }, "refreshInterval": 3600, // in seconds "longAction": "appleScript", "longActionAppleScript": { "inline": "activate application \"Calendar\"" } },
Thanks for sharing but this code isn't working now
It just leaves a blank space on my touchbar but nothing else. Has anyone got this to work? I'm on M1 Big Sur 11.2.1.
Config: { "type": "upnext", "from": 0, "to": 12, "maxToShow": 3, "autoResize": false },