Jump to content

Creating snippets or workflows programmatically


Recommended Posts

Hello,

 

I love Alfred, but I believe that the snippet section needs a little bit work. I find myself duplicating snippets for case sensitivity (e.g. >ty for thank you and >Ty for Thank you).

This becomes a bit annoying, so I have three ideas:

 

- Alfred supports this, but that would be a feature suggestion

- I create my snippet collections programmatically. I found that the snippet collections can be exported and imported. A snippet file seems to be a ZIP of JSONs. However, I cannot find any specification how these files are organized. In the filename, there seems to be some kind of UUID but it quickly becomes wild guessing. Can anybody tell me?

- I create snippet triggers, which is less preferred due to complexity. At least, I know that Dash (for coding) updates its associated Alfred workflow automatically. I know that there are libraries for workflow scripting, but for *creating* the workflows, what are the rules?

 

Thanks so much 🙂

 

PS: Please note if anybody would like to be informed about any kind of extension that might follow from this thread, i.e. in case I write some kind of snippet creator.

 

Edited by Xiphias
Link to comment
55 minutes ago, Xiphias said:

However, I cannot find any specification how these files are organized. In the filename, there seems to be some kind of UUID but it quickly becomes wild guessing. Can anybody tell me?

 

It's basically just what it looks like: a zip file (or folder when extracted) with a bunch of JSON files in it. You don't need an info.plist. I'm not sure if the filenames actually matter, either. The UID is just a UUID. That can be basically any string, as long as it's unique.

Link to comment

I think the info.plist is for setting prefix/suffix?

 

Do you know whether it's possible to automatically import (without manual action)? I only found a snippets.db in Application Support/Alfred, but that might not be the snippets store.

 

I'll give it a try. Thank you very much for your support.

 

Link to comment
15 hours ago, Xiphias said:

Do you know whether it's possible to automatically import (without manual action)?

 

It is. The "snippets" directory in your prefs bundle contains the canonical data. If you add or change files in that directory, Alfred should pick up the changes immediately. snippets.db is just a cache.

Edited by deanishe
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...