Jump to content

What is your workflow for developing these workflows?


Recommended Posts

I have a few ideas of what workflows I want to create but I am still wondering what would be the best way to go about creating them. Do you keep your workflows in some folder in your home directory like ~/workflows and then symlink it with the workflow directory that Alfred uses? Or do you develop and edit the code straight from there?

 

I am currently opening the workflows I want to edit and create with Alfred Extension (https://github.com/jmjeong/alfred-extension) and it is really nice however I still think that there may be a better way to do this. 

 

I hope you guys will share the way you go about developing your workflows and tools that you use. Right now I know of alfred-workflow (https://github.com/deanishe/alfred-workflow) and alfy (https://github.com/sindresorhus/alfy#users) that one can use to get help with creating the workflows.

Edited by nikivi
Link to post

I symlink my own workflows. Your code belongs in version control, not in an .alfredpreferences bundle in your Dropbox.

So that this works cleanly, for Python, I keep the actual workflow in a src subdirectory of the repo. That way, I can symlink the subdirectory to Alfred without the .git directory ending up in Dropbox, which isn't great. Also, building the workflow is as simple as zipping up the contents of the src directory. Keeps it nice and simple. When the repo root is the same as the workflow root, you have to be careful to exclude files during building. I've seen a few workflows that contained copies of themselves that contained copies of themselves that contained copies of themselves… because the author kept the built workflow alongside the source in his repo.

With Go, because it needs compiling anyway, I write a build script that puts the completed workflow in a build subdirectory, which can then be symlinked to Alfred or (its contents) zipped into a workflow.

I also keep all the code in external files and use Alfred's Script boxes like a shell to call the scripts. Alfred is a terrible programmer's editor, and you lose a lot of the benefits of git etc. if all your code is embedded in info.plist.

This has the overhead of an extra bash process, but that's about 0.01s when it isn't loading your dotfiles.

With regard to libraries like Alfred-Workflow, I don't think they're as necessary in Alfred 3 thanks to the ease of generating JSON compared to XML (at least in scripting languages). There's a lot more to AW than just generating XML/JSON, but with Alfred 2 you basically needed a library for the XML generation alone.

Finally, I generally write my workflows as command-line programs. If you have environment variables mapped to command-line flags, you can do some really neat stuff with workflow variables.

Link to post

Thank you for the writeup Dean,

 

It is extremely interesting. I will try to symlink my workflows too.

 

Just to make sure I understand it correctly. If I wanted to make a workflow, in your case, I would

 

1. create a folder with my workflow in my ~/workflows/cool_new_workflow

2. create an empty workflow in alfred preferences 

3. ln -s ~/workflows/cool_new_workflow {path to the workflow folder} ( not sure about this )

4. write all my code in the ~/workflows/cool_new_workflow folder and this code I can run from alfred in script filters

 

Is that how you go about making your workflows? Thank you a lot for any help. Also it would be curious to see some workflows that were done in go. :)

Link to post
  • Create a new directory for your project with a "src" subdirectory.
  • Create a new, empty workflow in Alfred.
  • Configure the workflow's name, bundle ID, icon etc. in Alfred's UI.
  • Reveal the workflow in Finder.
  • Move everything to the "src" subdirectory of your new project.
  • Delete the workflow from Alfred.
  • Symlink your workflow from the project directory: workflow-install -s src

workflow-install script.

Link to post

This worked like magic. Wow. Will put it under git and try and make the workflow. I am still very unsure on how to present my information on the alfred prompt and how I can work with different alfred environment variables but I think I can figure it out. 

 

Thank you for the script. 

Edited by nikivi
Link to post
  • 2 weeks later...

I use this build script for Python-based workflows.
 
They core operation is zipping everything in the src folder without a root folder in the zip archive. With Python, you should also exclude .pyc files, as they are specific to the (minor, I think) Python version you're running.
 
The script also pulls the workflow name and version from the source code to automatically name the generated file, so I can usually just run workflow-build src
 
Also, I forgot about my cookiecutter template. That's what I usually use when I start a workflow these days. Then I symlink it to Alfred and add the icon etc. in Alfred Preferences.

Link to post
  • 5 months later...

Hi @deanishe, do you think it is a good idea to put these build scripts into its own repo instead of just maintain as gists floating around? I was running into the symlink problems today and came across your scripts while scouring the forums. Having a widely-available set of scripts can be quite useful for enabling other Alfred workflow developers like me to avoid some of these issues. Thank you.

Link to post

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