icalBuddy Doesn't Work Within Keyboard Maestro. Mojave Calendar Permissions?

MODERATORS NOTE – 2021/08/24 13:22 CDT

See Post #6 for a patched version of icalBuddy.

I have a script which calls icalBuddy ¹ which works fine on its own, but in Keyboard Maestro I get an error saying I have no calendars.

Seems like an obvious case of Mojave's permissions getting in the way,

Keyboard Maestro and Keyboard Maestro Engine have "Full Disk Access" but I guess calendar access is still somehow different?

Anyone know a way around this? (And by anyone I'm guessing / hoping at least @peternlewis might have some trick up his sleeve)

¹ brew info ical-buddy -- because brew can't deal with interCaps.

Each application has a seperate Calendar access permission (System Preferences ➤ Security ➤ Calendar).

Whether it needs to be Keyboard Maestro Engine, or the script itself (or both) that needs access, I don't know for sure.

Well, that's what I expected… except that I cannot add either of them to the Calendar permissions. There's no + there like there is for Accessibility or Full Disk Access.

I ended up running the script via launchd (which prompted me to give the script access to calendars and+ reminders and then had that script call Keyboard Maestro. Inelegant, but it worked. Obviously would prefer to be able to do it within Keyboard Maestro, but not sure how.

I even tried dragging the Keyboard Maestro.app to the System Preferences window to see if that would do it, but no such luck.

I'm surprised that I didn't even get prompted whether or not I wanted to allow access.

1 Like

I'm having the same problem with iCalBuddy on Catalina.
I get the same 'No Calendars' error in Keyboard Maestro, Sublime Text, BBEdit and Typinator, whether I run a shell script, a python script, or an AppleScript.

Interestingly, Alfred 4, pops up the message asking for permission to the calendar and it works fine. So, I'm guessing it's something that could be fixed in KM (or the other apps). You can see the tccd errors in the console - I just don't know what to do with them.

Please let me know if you find a better workaround.

Just ran in to this issue today.

I'm trying to get the current event(s) from a specific calendar.

The AppleScript methods don't return repeating events, so those don't work for my use-case.

With icalBuddy I can run "/usr/local/bin/icalBuddy -ic "Time Blocks" -nc eventsNow" and get this, it's a bit slow, but it works. But as mentioned by the others, when running this within KM it returns "no calendars".

Ooh! I had forgotten about this post until I saw the followup message.

The good news is, you're in luck!

While trying to figure this out, I contacted the developer of LaunchControl, because it was not working in launchd either.

He took a look at the code, and found a bug in the way that icalBuddy was doing something. Apparently the bug didn't show up except in one of these situations like Keyboard Maestro, launchd, or TextBar.

He sent me a fixed version, which I am happy to share with y'all:

icalBuddyFixed.zip (54.1 KB)

I sent the fix to the current maintainer of icalBuddy, with the hopes that it would be integrated into the official release, but so far I have not heard anything back from him.

However, I have been using this without problem, and I hope it will work for you too.

1 Like

Fantastic, thank you! I tested it out and it works great!

1 Like

In case anyone ends up here in the future, there is a up to date repo with releases of the icalbuddy app here: https://github.com/DavidKaluta/icalBuddy64

I tried to contact the developer/maintainer of that Github repo to offer him the fix, but never heard back from him.

Last I tried, that version did not work with Keyboard Maestro either. If you have found otherwise, please let us know.

1 Like

Ah hah, ok great to know. I didn't try the version there, i just found it and was excited to find it and wanted to share. It looks like he's accepted a few pull requests, but for some reason the issues are not enabled in the repo.

Disabling issues is Github’s version of saying “I can't be bothered to look into anything that doesn't affect me directly.”

Yep. Do you happen to have the code that was changed? I can post a pull request to be merged in, or create a live fork on github so others have access to it?

Here is what Robby Pählig, developer of LaunchControl, Backup Loupe, and others wrote about this change:

I would not call it a proper fix because I don't know if it works for the built-in test suite or on other versions of macOS.

Here is the diff. It shows where the change happened and what has been changed:

And here's his patch:

diff --git a/icalBuddyFunctions.m b/icalBuddyFunctions.m
index f01283a..27f140e 100644
--- a/icalBuddyFunctions.m
+++ b/icalBuddyFunctions.m
@@ -624,7 +624,7 @@ void filterCalendars(NSMutableArray *cals, AppOptions *opts)

 NSArray *getCalendars(AppOptions *opts)
-    NSMutableArray *calendars = [[[[CALENDAR_STORE defaultCalendarStore] calendars] mutableCopy] autorelease];
+    NSMutableArray *calendars = [[[[[[CALENDAR_STORE alloc] init] autorelease] calendars] mutableCopy] autorelease];
     filterCalendars(calendars, opts);
     return calendars;

None of which means anything to me, really.

Thanks! I've created the pull request: https://github.com/DavidKaluta/icalBuddy64/pull/3
It's out of our hands now :slight_smile:


Thanks! Here's hoping!

I tried version 1.10 and 1.10.1 and I still get the "no calendars" error. Does anyone have a working version of icalbuddy that works on Catalina 10.15.7?

This is the patched version that I am using, and it works on Catalina and Big Sur.

icalBuddyFixed.zip (54.1 KB)


Thanks! I tried it but still get no calendars. Is there something I should do with permissions?

BTW, it does work from the command line, but from KM, I get this:

Screen Shot 2020-11-04 at 7.07.08 PM

If it works from the command line then the permissions should be OK. You're 100% sure that you are using the same version in Keyboard Maestro that you are using on the command line, right? You might try renaming the version from Dropbox as "icalBuddyFixed" just to differentiate it from the one you can get from brew.

If it still does not work, we might need to ask Peter for assistance.

1 Like

Thanks. Very strange, can you try the dropbox link? I see a file with no extension called icalBuddy that isn't a text file and I can't figure out how to open it. (I can't tell if I was opening another file yesterday. Hmm.)