Jump to content

Problem with File Type in a Script Filter when an environment variable is set


GuiB

Recommended Posts

Since this is what I think the standard way to set an environment variable from a Script Filter, I think this should be working, but feel free to move this post to the feature request if this the normal behaviour and not a bug.

 

When building a workflow that works with files and folders, I like to allow to run actions on those files/folders. So, since the File Action is made for that, I like to just activate it on my script filter output item by using my File Action shortcut (sets to cmd-cmd in my case). However, when I want to set an environment variable inside the Script Filter, then the File Action shortcut doesn't work anymore even if "type" is set to "file" in the JSON. Since this environment variable is used when I normally activate the selected item on my workflow by pressing enter and could change based on which item of the Script Filter is activated, I need to set it inside the Script Filter and not after or before, but would like to keep the default behaviour of the " 'type': 'file' " item.

 

Here is a workflow to demonstrate this: https://nofile.io/f/xZGFinuS44I/Script+Filter+-+File+Type+with+File+Action+-+Test.alfredworkflow

 

Let me know if something isn't clear enough! Best!

Link to comment
Share on other sites

@GuiB I have actually addressed this recently after this thread:

 

https://www.alfredforum.com/topic/10427-typefile-is-ignored-when-variables-are-also-set-changes-made-for-341-b858-pre-release/

 

You can now simply add variables per item, for example (using your workflow):

 

Second item in your list:

{
    'title': "Desktop",
    'subtitle': "By setting env var = file action doesn't work",
    'type': "file",
    'arg': "~/Desktop",
    'variables': {
        'varName': "varValue"
    },
    'icon': {
        "type": "fileicon",
        "path": "~/Desktop"
    }
}

I did update the documentation, but didn't make a big deal about highlighting it:

 

https://www.alfredapp.com/help/workflows/inputs/script-filter/json/#variables

 

Let me know if you have any problems with this :)

 

Cheers,

Andrew

Link to comment
Share on other sites

Oh yes, I briefly remember having read something related to environment variables in an release note, but I read it fast and it seems I didn't clearly catch this information! Thanks for letting me know and I prefer this method than my internal JSON! Sorry for taking your time on this then, have a nice day! 

Link to comment
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
×
×
  • Create New...