Jump to content
roosterboy

Alfred env variable for keyword trigger

Recommended Posts

How about Alfred setting an environment variable for the keyword used to trigger a workflow (if any)? I can get alfred_workflow_bundleid and alfred_workflow_name but if there are multiple keyword triggers in a workflow, I can't tell which one triggered the action. That could be useful information to have from time to time.

Share this post


Link to post
Share on other sites

I often use AppleScript to call back into my workflows (e.g. to jump back up a level or two, or reopen the list of config options after one has been changed).

 

This works okay, but it's fragile because it will cease to work if a user changes a keyword. If there were a way to determine the keyword used, this could be made much more robust.

Share this post


Link to post
Share on other sites

Re-running a workflow based on a keyword is also fragile, as there may be multiple Inputs with the same keyword, and you'd get unexpected results (i.e. multiple workflows running on calling back for that keyword).

 

It's better to use an external trigger wired into the Keyword Input and call back on that instead which takes you directly into the keyword you want by specific identifier.

Share this post


Link to post
Share on other sites
1 hour ago, Andrew said:

It's better to use an external trigger wired into the Keyword Input and call back on that instead which takes you directly into the keyword you want by specific identifier.

 

But that doesn't work with Alfred's history.

 

I appreciate the potential fragility of calling back into a workflow via keyword, but that's a potential problem vs the very real usability issue of External Trigger mode not allowing you to back up or reopen Alfred at where you'd just drilled down to, forcing you to start all over again instead.

Share this post


Link to post
Share on other sites
8 hours ago, deanishe said:

I appreciate the potential fragility of calling back into a workflow via keyword, but that's a potential problem vs the very real usability issue of External Trigger mode not allowing you to back up or reopen Alfred at where you'd just drilled down to, forcing you to start all over again instead.

 

It sounds like we need some way to call a Keyword Input directly from external AppleScript (via some sort of id, and providing an argument). This would allow Alfred to make that Input unique (much like pressing return on the result placeholder for that input, and the other results are removed), while populating the keyword and provided argument for the history.

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, Andrew said:

It sounds like we need some way to call a Keyword Input directly from external AppleScript (via some sort of id, and providing an argument)

 

Well, Script Filters in my case, but that would solve my use case, and setting a variable to the entry point's ID would solve @Aviesh's.

 

More generally, being able to call arbitrary elements by ID instead of having to route control flow through a bunch of Filter or Conditional elements would be helpful. For example, you could show an error message in a Notification from anywhere within the workflow without having to wire everything into the Notification element (though this particular case can also be handled via an External Trigger).

Edited by deanishe

Share this post


Link to post
Share on other sites

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