Jump to content

Dynamic workflow subtexts?


Recommended Posts

You can set the "Subtitle" field to any Alfred variable to make it dynamic. For example, write "{query}" inside the Subtitle field and you will get your query written in the subtext. For the Keyword and List Filter objects, you would need to have a another entering point to your workflow so you can set your variable before showing it, but if you want it directly written when you write your workflow Keyword, then you'll be better to use a Script Filter so you can run whatever you want to set your subtitle field directly.

Link to comment

Thanks – based on your suggestions I was able to find a way to do it without variables: I made a script filter that returns one item with the same title as the script filter's placeholder title and the desired subtitle. So when I finish typing the keyword the workflow row is replaced by the script filter row, but they look the same (apart from the extra subtitle).

 

The only drawback is that the subtitle doesn't appear until the entire keyword is typed, since the script filter isn't run until then. It seems the same would be true if I was dynamically assigning a variable in the script filter, as you suggest.

 

Any suggestions to how I can get around this and have a dynamic subtext displayed as soon as the workflow option appears on the screen, even if I haven't fully typed the keyword yet?

Link to comment

About the Script Filter, I didn't say you needed to assign a variable before using it inside, but more (or what I meant) that you can set the Subtitle string to whatever you want inside the script (so it could be an environment variable, a local variable, a string...). However, for the Keyword and List Filter object, since they don't run a script when you access them, then you need to have set a variable before showing it.


About the subtitle text when you are searching in Alfred for your workflow, as you said, the output when doing a global search doesn't run your script until you have written your full keyword since this would slow down a lot Alfred since it will execute every script while searching... So you will get many undesirable events. However, Alfred let you assign a subtext for this global search and is the "Placeholder Subtext" field in the Script Filter (3rd line of the Script Filter object). This field works the same way as the field of the same title in the List Filter and the "Subtext" field in the Keyword object. Therefore, it won't be as dynamic as the output of a Script Filter... You can access an environment variable, but you can't output a small script...


So, in your case about listing the last downloaded file, I don't think you will find an easy way to set this Placeholder Subtext to your file name/path, but if you can set an environment variable before searching for the Workflow Keyword...


Also, if you don't know this and it's useful to you, note that when searching a keyword you can press tab on your selection (when you are over the keyword line that you want) and Alfred will expand your query to the keyword so you will run your Script Filter and see the output in the Subtitle without activating the workflow.

 

Hope this helps!

Edited by GuiB
Link to comment
  1. Add a workflow variable to the configuration sheet called LAST_DOWNLOAD
  2. Change the Subtext of your Keyword/Script Filter to {var:LAST_DOWNLOAD}
  3. When a download is complete, update the saved value with AppleScript: tell application "Alfred 3" to set configuration "LAST_DOWNLOAD" to value ...
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...