koekeishiya / skhd

Simple hotkey daemon for macOS
MIT License
6.07k stars 204 forks source link

Can't access calendar data using icalbuddy #104

Open Peeja opened 4 years ago

Peeja commented 4 years ago

I'm trying to use icalBuddy to get the current calendar event (icalBuddy eventsNow), but icalBuddy reports:

error: No calendars.

That's not correct, though, and doesn't match what I get running it from iTerm. That's probably because i'm on Mojave, and when I run it from iTerm (the first time), I'm prompted to allow iTerm to access my calendars, which I've allowed. But when I run it from skhd, I never get prompted, and there doesn't appear to be a way to manually add it.

Is there a trick to enabling this permission for skhd, which I think will fix the problem?

Peeja commented 4 years ago

It looks like iTerm had to do some work to support this, and so skhd may need to as well: https://gitlab.com/gnachman/iterm2/issues/6977

koekeishiya commented 4 years ago

This is a privilege that the icalBuddy binary should have, and not all the applications that act as a launcher of said binary. As far as I can tell, icalBuddy has not been actively maintained in a long time?

Peeja commented 4 years ago

Hmm, that hasn't been my experience with command line apps. Generally, the permissions seem to be based on the "topmost" process. I think the idea is that Apple doesn't want every app that shells out to a tool like icalBuddy to have the same set of permissions, so in this case macOS knows that I'm comfortable using icalBuddy directly, but doesn't want to assume that I'm comfortable with skhd having access to my calendar data.

Notably, running icalBuddy eventsNow from the terminal shows me my events, so icalBuddy itself has the privileges it needs.

koekeishiya commented 4 years ago

Looks like the developer of iTerm solved the issue by adding a key with the name NSCalendarsUsageDescription to the applications .plist file. I don't know how that would translate for single binary daemon applications.

Peeja commented 4 years ago

Yep, looks like imagesnap has similar problems: https://github.com/rharder/imagesnap/issues/26

There are some…interesting hacks in that thread. Nothing seems terribly nice. I'm resorting to running this particular keybinding from Alfred for now, but if anyone comes up with a way to enable this for skhd, I'd much rather keep it there.