amoose136 Posted May 27, 2016 Share Posted May 27, 2016 The standard file filter does not allow for custom xml in results. Is there a way to replicate its functionality with script filters without compromising speed too much? Link to comment
deanishe Posted May 27, 2016 Share Posted May 27, 2016 Yes. Just spit all the results out of your Script Filter and select the "Alfred filters results" box. Alfred will call your Script Filter once to get the results, then take care of the filtering for you. It won't call your Script Filter again until you leave and restart the workflow. Link to comment
amoose136 Posted June 27, 2016 Author Share Posted June 27, 2016 Yes. Just spit all the results out of your Script Filter and select the "Alfred filters results" box. Alfred will call your Script Filter once to get the results, then take care of the filtering for you. It won't call your Script Filter again until you leave and restart the workflow. I'm sorry this isn't entirely clear to me. I don't have a script filter right now. I have a file filter that works but I want to replicate the behavior of the default file-filter block using a script filter. In particular I'm searching through contacts from Address Book right now and rather than just show the contact name, the default contact icon, and "View in Alfred", I'd like it to be the contact name, the contact's picture if it exists as the icon, and the subtext can be any option I choose from the contact card. What you seem to be suggesting is that I generate xml for all the contacts and pass that to Alfred and let it filter it down. This seems like it would be slow if you have a lot of contacts. I guess I could cache this xml somewhere and update it in the background each time the script is run but that doesn't seem very elegant. I would think you would just run the script on a partial match of the first few characters (1 or 2) so as to dramatically reduce the subset and then filter it from there. Link to comment
deanishe Posted June 27, 2016 Share Posted June 27, 2016 (edited) If you want Alfred to do the filtering for you, you need to give it a list of all the data. Otherwise you need to handle filtering the results based on the query yourself. You'd likely want to do that anyway in this case, as Alfred only performs a "word starts with" comparison on the item title, and you'd presumably want to search other fields, too. My MailTo workflow uses the contacts database, and I found the best way was to cache all the contact data in a background process and only use the cached data in the workflow. The AddressBook API was too slow for my liking (I was probably using it wrong). Edited June 27, 2016 by deanishe Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now