Jump to content

Alfred Dictionary in my Workflow


Recommended Posts

Posted

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

Posted

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).

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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 !

Posted

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.

Posted

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. 

Posted (edited)

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

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...