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

The icalBuddy file is an executable file, so you should just download it, make it executable (chmod 755 icalbuddy) and save it to /usr/local/bin/icalbuddy or /usr/local/bin/icalbuddyfixed

2 Likes

It worked. Thanks!

1 Like

Has anyone else encountered this kind of issue when using icalBuddy in KBM? I am using the patched version linked above (thanks, @tjluoma) and when I run it in the terminal, I get the desired output (for use in Obsidian with the Day Planner plugin):

- [ ] 08:00 Writing
- [ ] 09:00 Deep Work
- [ ] 10:00 Planning mtg
- [ ] 13:00 Weekly review

I am using these flags:

icalBuddy -b "- [ ] " -ea -nc -f -iep datetime,title -eed -po datetime,title -ps "| |" eventsToday

But when I use the same flags in KBM as "Execute shell script" and "paste results" into a text file, the output is really strange, including some non-printing characters:

e[22me[39me[49me[24me[25me[1m- [ ] e[33m08:00e[22me[39m e[33mWritinge[39m
e[1m- [ ] e[33m09:00e[22me[39m e[33mDeep Worke[39m
e[1m- [ ] e[33m10:00e[22me[39m e[33mPlanning mtge[39m
e[1m- [ ] e[33m13:00e[22me[39m e[33mWeekly review[39m

Is this an encoding issue? Any advice?

1 Like

Not an encoding issue. Those are ANSI escapes that are coming about because you are using the -f flag:

-f, --formatOutput
Use ANSI escape sequences to format the output and hopefully make it more readable.

Try removing the -f and see if it works better.

Also - welcome to the forums! It’s a great place on the web. Glad to have you with us.

1 Like

Brilliant! Removing the -f flag fixed it. Much appreciated.

1 Like

This fixed version appears to be broken again in MacOS Ventura.

I'll confirm that the original and the fixed version returns "Error: no calendars" in Ventura. I've gone through all permissions under Privacy and Security. The exact same script that fails in KBM works successfully in Terminal. Terminal is the only app in Calendars for Privacy and Security. @peternlewis if it works in terminal why would we get this error when launched through KBM?

What script?

If it is a script, then Keyboard Maestro Engine presumably needs automation permission to control Calendars.

I am pretty sure Ventura has issues with controlling Contacts. I don't know about Calendars.

OK, I just tried my Ventura Mac, and it had no trouble accessing the calendars or events.

Keyboard Maestro needs to have Calendars permission, and Keyboard Maestro Engine (or maybe Keyboard Maestro) needs Automation permission to control Calendars.

Other than that, I don't know why the script would fail.

icalBuddy is run via a script in KBM.

In MacOS Ventura, I don't see any way for me to add a specific type of permission for KBM or KBM Engine except for the Full Disk Access, Bluetooth, Media & Apple Music, Accessibility, Input Monitoring, Screen Recording, , App Management and Developer Tools permissions. I enabled full disk access and developer tools for KBM but Automat, Contacts and Calendar do not have the ability to add apps manually. And I don't know how to add KBM Engine manually because it does not show in the Apps list.

I found this in the Obsidian Forum that appears to be the same issue and the user resolved the issue by updating the entitlements for the Obsidian app which required an XML file and resigning the executable with a trusted certificate. This does not seem like the right way to fix this because most people are not going to know how to do this. Here is a link to the thread which discusses this same issue:

Is there a way for me to manually add a permission for KBM and KBM Engine without the app specifically asking for it? Or is it the responsibility of the program being run in the script to ask for the permission? Thanks for your assistance with this!

Generally, you just run a script that asks for the calendars, eg:

tell app "Calendar" to calendars

It should ask you both for Automation control of Calendar, and access to the calendars.

As for manually adding it, that varies from setting to setting.

Duh...

What's the script?

Provide something testable.

Sorry about that. Didn't know what level you were at. I abandoned icalBuddy in favor of shortcuts.

I've got a similar icalBuddy issue...

I am able to run icalBuddy in Terminal just fine, however when I try to run it in KBM I get nothing – no output at all.

I'm using the KBM action "Execute text script" with output to a window:

#!/bin/zsh
/opt/homebrew/bin/icalBuddy -npn -nc -ps "/: /" -iep "datetime,title" -po "datetime, title" -b "\n\n### " -tf "%I:%M %p" -eed  eventsToday

But no output at all. Again, it does work in Terminal directly.

Start at the beginning and, in Terminal, run which icalBuddy -- make sure the output of that is matched by the path used in the action's script. If that's OK start checking your other environment variables.

1 Like

So the problem is that you have to get KBM to trigger the approval prompt for calendar access. You can't just rely on terminal or your other apps to have the permissions. And there's no way to manually add this permission via the System Preferences panel.

The way I finally achieved this was by adding a KBM macro that ran an AppleScript of one line:

tell app "Calendar" to calendars

Invoke that macro. When the AppleScript runs the first time, It'll prompt you to grant access to Calendars. Say yes and you'll see the KBM is now has Calendar permission in the System Preferences panel.

After that, you're good. You can delete the temporary macro.

2 Likes

If you're running into this post-upgrade to Sonoma, and had to update a (new?) option under Settings/Privacy & Security/Calendars, and Options for Keyboard Maestro. Specifically enabling "Full Calendar Access"