deanishe

Modifiers can alter item values other than subtitle

4 posts in this topic

So, this popped up over in the help forum, but this is a better place for it to solicit feedback, methinks.

Currently, Alfred allows you to specify alternate subtitles for the result items returned by Script Filters, so that you can let the user know which action would be run.

Looks like this:

<item arg="/path/to/Ideas.txt" uid="/path/to/Ideas.txt" valid="yes">
    <title>Ideas.txt</title>
    <subtitle>Open file</subtitle>
    <subtitle mod="cmd">Reveal file in Finder</subtitle>
    <subtitle mod="alt">Trash file</subtitle>
</item>

Whereby the Script Filter is connected to three different Actions.

 

The suggestion is to turn the alternate subtitles "inside out" and add a <mod> (or <alternate>) tag that can override not just the subtitle, but any of the item's parameters (that make sense):

<item arg="/path/to/Ideas.txt" uid="/path/to/Ideas.txt" valid="no">
    <title>Ideas.txt</title>
    <subtitle>Search in Ideas.txt</subtitle>
    <icon type="fileicon">/path/to/Ideas.txt</icon>
    
    <mod key="shift" valid="yes" arg="/path/to/Ideas.txt">
        <subtitle>Open this file</subtitle>
        <!-- the super-smart workflow has figured out the
             default app for this filetype -->
        <icon type="fileicon">/Applications/Sublime Text.app</icon>
    </mod>
    <mod key="cmd" valid="yes" arg="/path/to/Ideas.txt">
        <subtitle>Reveal in Finder</subtitle>
        <icon type="fileicon">/Applications/Finder.app</icon>
    </mod>
    <mod key="alt" valid="yes" arg="/path/to/Ideas.txt">
        <subtitle>Trash</subtitle>
        <icon type="icon">trash.png</icon>
    </mod>

</item>

This would have a few advantages:

  • It's possible to set an item to invalid for if, say, you want to require an additional argument by default, but override that in alternate actions. Currently, an action is always valid or never valid (this was the starting point).
  • You can change not just the subtitle, but also the title and/or the icon, providing more and better contextual information (don't forget, some users turn off subtitles)
  • You can change the arg. This means you can avoid a plethora of Run Scripts/Open URL actions and instead generate alternate URLs (e.g. to different search engines) right in your Script Filter and connect it to just one Open URL action. The same goes for copying different representations of data (e.g. colours, emoji or other non-ASCII text) to the pasteboard. (This would also require Alfred to allow multiple connections to the same Action/falling back to the "bare" action if there isn't another connection for the modifier)
  • By avoiding hard-coded actions, it makes it easier to allow users to configure workflows without having their changes overwritten by a workflow update (which necessarily happens to any user-added actions and connections in a workflow)

It wouldn't make sense to be able to override all of an item's options (e.g. uid, copy text and large text).

 

It strikes me (and Florian) as a powerful addition.

 

What do you think?

Edited by deanishe
idea4IT and Tyler Eich like this

Share this post


Link to post
Share on other sites

Yep, I really like this. It would take a bit of an architectural change (allowing a single result item to have multi state validity) so it may not be a minor release... but I can definitely see something like this coming to workflows!

deanishe and smarg19 like this

Share this post


Link to post
Share on other sites

Just wondering, was this ever added? I am creating a workflow and would like to change the icon when pressing a modifier. I can't get it to work so probably not but it would be a very nice addition.

Share this post


Link to post
Share on other sites

It was, but only partially. Sadly, you still can't change the icon. Hopefully, Andrew will add that at some point.

Edited by deanishe

Share this post


Link to post
Share on other sites

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