Jump to content
kigster

How to programmatically (from BASH/iTerm) to add/import a workflow from a .alfredworkflow file?

Recommended Posts

Hi! I have been a user of Alfred (+ Powerpack) for years, but only recently decided to invest more time into customizing it with the workflows I thought were helpful.

 

As I am a software developer, I generally setup any new Mac OSX environment using a completely automated installer: https://github.com/kigster/pullulant

 

I wanted to add to Pullulant a simple bash script for installing Alfred. I can install the software itself using Homebrew, and then I was hoping to download and install my favorite workflows.

 

I have now spent over an hour searching online, and I am absolutely stunned to find out that Alfred, the supposedly tool for automating your OS-X life, is itself so difficult to automate!!!

 

What I want is a single line command I can run in Terminal (or iTerm, i.e. bash), that tells Alfred to import the given workflow. Since Alfred insists on choosing a category for a workflow (which is completely useless in my opinion), I would imagine that this command would need to tell Alfred what category to assign it. 

 

Right now I am able to do this:

open $(curl -s -L -O -w %{filename_effective} \
   https://github.com/packal/repository/raw/master/com.alfredapp.mdeboer.atom/atom.alfredworkflow)

And as you would expect, curl downloads the file, OSX then opens Alfred, which then stays open like a village fool waiting for me to choose a category for it, and I can't, for the love of life, my laptop or the universe, find a way to make this entire process non-interactive, so that I can run it in a goddamn loop and be done with it.

 

Why!? Why is it so hard? LOL. Cry. LOL. Cry.

 

Sorry, it's very late, and I am getting a bit delirious. I do not mean to offend anyone, I just hoped that I could find a solution without having to post a new question in the forum, because even after searching this entire forum for "install", "command line", "bash", "terminal", "non-interactive" I found nada.

 

Your truly,
Konstantin

https://github.com/kigster

Edited by kigster

Share this post


Link to post

I wanted to add to Pullulant a simple bash script for installing Alfred. I can install the software itself using Homebrew, and then I was hoping to download and install my favorite workflows.

 

 

 

The .alfredworkflow files are actually just a zip of the workflow.  You can unzip them into Alfred's Workflow folder (within the Alfred.alfredpreferences) and Alfred will automatically load them ready for use.

 

It's worth mentioning that Alfred does a number of validations and checks when importing through the UI which would be skipped if you manually placed a workflow in Alfred's workflow folders, but if these are from trusted sources such as your own, then this is absolutely fine :)

 

Cheers,

Andrew

Share this post


Link to post

Hi! I have been a user of Alfred (+ Powerpack) for years, but only recently decided to invest more time into customizing it with the workflows I thought were helpful.

 

As I am a software developer, I generally setup any new Mac OSX environment using a completely automated installer: https://github.com/kigster/pullulant

 

I wanted to add to Pullulant a simple bash script for installing Alfred. I can install the software itself using Homebrew, and then I was hoping to download and install my favorite workflows.

 

I have now spent over an hour searching online, and I am absolutely stunned to find out that Alfred, the supposedly tool for automating your OS-X life, is itself so difficult to automate!!!

 

What I want is a single line command I can run in Terminal (or iTerm, i.e. bash), that tells Alfred to import the given workflow. Since Alfred insists on choosing a category for a workflow (which is completely useless in my opinion), I would imagine that this command would need to tell Alfred what category to assign it. 

 

Right now I am able to do this:

open $(curl -s -L -O -w %{filename_effective} \
   https://github.com/packal/repository/raw/master/com.alfredapp.mdeboer.atom/atom.alfredworkflow)

And as you would expect, curl downloads the file, OSX then opens Alfred, which then stays open like a village fool waiting for me to choose a category for it, and I can't, for the love of life, my laptop or the universe, find a way to make this entire process non-interactive, so that I can run it in a goddamn loop and be done with it.

 

Why!? Why is it so hard? LOL. Cry. LOL. Cry.

 

Sorry, it's very late, and I am getting a bit delirious. I do not mean to offend anyone, I just hoped that I could find a solution without having to post a new question in the forum, because even after searching this entire forum for "install", "command line", "bash", "terminal", "non-interactive" I found nada.

 

Your truly,

Konstantin

https://github.com/kigster

 

If you want to find some code that does this, then you can look at the Packal updater. If you want some more specific code, then you can look into the v2 branch on GH, especially this file: https://github.com/shawnrice/packal-updater/blob/2.0.0/Libraries/Workflows.php.

 

It's all in PHP.

 

If you're just trying to install them and aren't worrying about upgrades or accidentally getting default hotkey values that are set in the distributed workflow, then you can do:

wget http://path/to/workflow.alfredworkflow
unzip workflow.alfredworkflow
mv workflow ~/path/to/installed/workflows/

Share this post


Link to post

The .alfredworkflow files are actually just a zip of the workflow.  You can unzip them into Alfred's Workflow folder (within the Alfred.alfredpreferences) and Alfred will automatically load them ready for use.

 

It's worth mentioning that Alfred does a number of validations and checks when importing through the UI which would be skipped if you manually placed a workflow in Alfred's workflow folders, but if these are from trusted sources such as your own, then this is absolutely fine :)

 

Cheers,

Andrew

 

I know it's been a while since the last time I asked this, maybe something changed. 

 

Like you mention that an install would be as simple as unzip the .alfredworkflow and place it in the alfredpreference directory, is there a similar method for updating existing workflows? 

 

I recall a while back that the problem when updating was the stripping a migration of hotkeys and keywords.

 

BTW, this is looking to continue my work on https://github.com/jonathanwiesel/awm

 

Regards,

Jonathan

Share this post


Link to post

If anything, it's probably more complicated in Alfred 3, as there's more stuff for the user to fiddle with (Workflow Environment Variables) that will also need migrating.

 

And there's the additional issue of determining whether a workflow is compatible with Alfred 2 before you go overwriting previous versions.

 

The lack of a different file extension for Alfred-3 workflows is currently a massive issue wrt not breaking all the Alfred-2 installs of my workflow :(

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