Jump to content

Problem with direct use of mdfind in a script filter


Recommended Posts

I'm trying some workflows that use mdfind directly. E.g., I have a trial one that does a bash script:

 

mdfind "kMDItemContentType == com.apple.ical.ics.event" >log.txt

 

Unfortunately, when I use this command in the script filter the contents of log.txt are different from the results that I get when run the same mdfind command from a normal shell.

 

Can anyone explain why there is this difference? How can I avoid it? In this case the results I actually want to find are missing when the workflow runs the command :-(

 

thanks,

Tony

 

Link to comment

I'm trying some workflows that use mdfind directly. E.g., I have a trial one that does a bash script:

 

mdfind "kMDItemContentType == com.apple.ical.ics.event" >log.txt

 

Unfortunately, when I use this command in the script filter the contents of log.txt are different from the results that I get when run the same mdfind command from a normal shell.

 

Can anyone explain why there is this difference? How can I avoid it? In this case the results I actually want to find are missing when the workflow runs the command :-(

 

thanks,

Tony

 

I can't imagine what would be causing this unless its a result of Alfred not importing your profile but I didn't think that would be an issue when using mdfind. I'll have a chat with Andrew and see if he knows more about what would cause this issue.

Link to comment

Thanks. I thought of the profile as well. Checked the environment in both places but I couldn't see anything missing or present that I thought could be causing this behaviour.

 

Check OS X's Security & Privacy > Privacy prefs to see if Alfred has access to both Contacts and Reminders, if not, this could explain a possible difference.

Link to comment

Thanks for the prompt response. I checked the Privacy settings. Alfred *does* have access to Contacts and Reminders.

 

However, it doesn't have access to the Calendar which is the aim of my query above. Unfortunately, I can't see how to add that permission to test whether it makes a difference. Alfred doesn't appear in the Apps panel for Calendar under the Privacy settings (I also tried dragging the app in). Does that mean that this permission is irrelevant to Alfred?

Link to comment
  • 1 month later...

I've investigated a bit further. It turns out that the Calendars setting in the Security & Privacy preferences *is* vital. If I go to that preference setting I see Things.app and iTerm.app and both are enabled. If I disable iTerm.app then the mdfind shell command listed above fails to find anything in ~/Library/Calendars. In other words, with the permission turned off for iTerm mdfind run in an iTerm behaves as it does from within an Alfred workflow.

 

So, this seems to indicate strongly that Alfred needs to be given permission to access Calendars for mdfind so that it can find all of the events.

 

Since Alfred doesn't appear in the list of apps under the Calendars setting now, I can't turn that permission on. Will it be necessary for Alfred to request that permission somehow?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...