Jump to content

How to tell in workflow code if user has Alfred 2 versus 3?


Recommended Posts

Is there a way inside a workflow's source code to determine whether the user has Alfred 2 or 3?

 

My workflow stores information in the OS application cache/storage directories, e.g.

~/Library/Application Support/Alfred 2/Workflow Data/
 

I want to update my workflow to use the correct directory for the version of Alfred that's being used, but I don't currently see any way of doing that.

Link to comment

It means that you may have to re-factor your code into Alfred-specific and generally-useful parts.

 

Note that if you edit your workflow in Alfred 3, it will no longer be compatible with Alfred 2 (regardless of whether you use any 3-only features or not).

Link to comment

Reasonable suggestion.  However the library my workflow relies heavily on is this one: https://github.com/phyllisstein/alp which references Alfred's storage and cache paths.

 

For now I think I'll have to see this is as just being a tradeoff.  The best solution for right now is probably setting the environment variables manually if I need to test outside of Alfred.

 

In the future why not have Alfred expose some sort of developer utility (i.e. a bash script) that bootstraps all the Alfred environment variables.

 

Thanks.

Edited by benknight
Link to comment

That won't work, I'm afraid. alp was discontinued quite some time before Alfred added environmental variables. It has the cache and data paths hard-coded into it.

 

You'll either need to fix alp yourself or use a more up-to-date library. That runs fine outside of Alfred, as it falls back to reading info.plist if the environment variables aren't set. Newer versions default to Alfred 3's data/cache paths in that case, however.

Link to comment

No, I mean that phyllisstein quit working on it years ago. It doesn't even support a few Alfred 2 features, like modifiers.

 

There are no official libraries for Alfred.

 

As far as Python goes, I'm pretty sure my library is the only one that's properly maintained (i.e. kept up to date with Alfred's features).

 

OTOH, Alfred's added a lot of features over the last couple of years (environment variables, the debugger and especially JSON feedback in Alfred 3) that make libraries far less necessary.

Edited by deanishe
Link to comment
On 11/9/2016 at 8:19 PM, deanishe said:

As far as Python goes, I'm pretty sure my library is the only one that's properly maintained (i.e. kept up to date with Alfred's features).

 

On 11/9/2016 at 10:21 PM, benknight said:

I'll consider switching over to your awesome-looking Python package and dropping alp ;)

 

@benknight I’ll add to @deanishe’s point above that he’s also a very active member on these forums, keeping up to date (and suggesting and discussing) with new features as well as helping users daily. I say that to point out he’s likely the library author — of any language — more in touch with the community. If you’re going to trust any library, trust his. Not only will it likely work correctly for your needs, if it doesn’t you can rest assured you have an interested maintainer that will want to fix the bug.

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