Jump to content
odetinin

Alfred Dictionary in my Workflow

Recommended Posts

Hello:

 

I would like to incorporate Alfred built in Dictionary commands in to my own workflow.

Basically, I want to extend built in functionality by adding my custom actions after, let's say, spell check command is done. How can I do it ?

 

Thanks,

Oleg

Share this post


Link to post

In short, you can't.

Alfred doesn't expose its built-in features (like its dictionary, calculator, contacts search etc.) to workflows.

If you want to use OS X's built-in dictionary (which I believe Alfred also uses), you need to use [Dictionary Services](https://developer.apple.com/library/mac/documentation/userexperience/conceptual/dictionaryservicesprogguide/access/access.html#//apple_ref/doc/uid/TP40006152-CH5-SW1).

Share this post


Link to post

There is a python script out there somewhere that can interface with the system dictionary. You just run it with "py scriptname.py word_to_define"; it sends back the definition and a few other things; it's limited, but that might work for you.

 

Otherwise, yes, you need to follow what Dean said above. Apparently, Apple doesn't want you messing with their dictionary.

Share this post


Link to post

Yeah, the system Python has the necessary libraries to interface with Cocoa frameworks.

In theory, you can do with Python most things you can with native code.

It can be a bit torturous to figure out the Python equivalent for an Objective-C call, and fast it is not (compared to native code). It'd be plenty fast for this use case, though.

Share this post


Link to post

Great ! Thanks a lot for your replies.

 

My only wish is to make Alfred to expose it's built-in features to custom workflows. Should not be THAT difficult.

Share this post


Link to post

It would be great if Alfred exposed a bit more of its internals to workflows, but that's a pretty major amount of work.

Practically speaking, it's basically untenable for Alfred to provide an API in all the languages it supports for workflows.

It would be possible for Alfred to provide a richer AppleScript dictionary with access to its built-in functionality, but a lot of that represents relatively thin wrappers around core OS X functionality, which is naturally accessible to workflows directly, and without the requirement of using AppleScript, which is a horrendous language.

Share this post


Link to post

True. But having some type of "hooks" for Alfred built-in workflows, e.g. before it's called, after it's finished, where I can plug in my own code will open so many possibilities to tailor Alfred exactly for your needs !

Share this post


Link to post

Alfred doesn't have "built-in workflows". It has built-in functionality closely tailored to the data they're handling.

 

How do you propose these "hooks" should work? How should Alfred pass, for example, a contact to your hook?

 

I think it's a good idea, but an implementation just doesn't fit at all with Alfred's current  execution model.

Share this post


Link to post

I called them "workflows" just to put it in a simple perspective. Sure, these are "built-in" functionalities.

 

Just as a concept: a new item could be introduced in a workflow creation screen which will contain a list of "built-in" functionalities. A passing of parameters could be done the same way it is done now: via stdin/stdout. 

Share this post


Link to post

I called them "workflows" just to put it in a simple perspective. Sure, these are "built-in" functionalities.

 

Just as a concept: a new item could be introduced in a workflow creation screen which will contain a list of "built-in" functionalities. A passing of parameters could be done the same way it is done now: via stdin/stdout. 

 

I know you know they're not really workflows, but it confuses me when people use the wrong words for things: I unfortunately tend to take things very literally :(

 

Your use of "hooks" also had me thinking about something completely different, with workflows somehow registering their callbacks with Alfred.

 

So sorry, I was firmly holding onto the wrong end of the stick.

 

The stdin/stdout idea is interesting, but I'm not sure it'd fit well in the workflow creation screen. I mean, what would these elements be and where would they go? Would there be two new columns and element classes?

 

So, how about if you could call Alfred with a query and have the results returned to your workflow instead of the user, either via XML on stdin/stdout or (more likely) the existing AppleScript API?

 

Of course, that won't work if a user isn't using the expected default keyword, but that's not a new problem: workflows already routinely use Alfred's AppleScript support to call themselves.

 

Then you could also call other workflows, not just Alfred's built-ins. And I'd be able to implement the File Filter blacklisting Andrew won't :)

 

It wouldn't require any large changes to the way Alfred works, either.

Edited by deanishe

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...