powerpack
powerpack copied to clipboard
Support variables
From the Alfred workflow documentation
Variables / Session Variables
Variables within a variables object will be passed out of the script filter and remain accessible throughout the current session as environment variables.
In addition, they are passed back in when the script reruns within the same session. This can be used for managing state between runs as the user types input or when the script is set to re-run after an interval.
{ "variables": { "fruit": "banana", "vegetable": "carrot" }, "items": [ ... ] }
See the built in "Advanced Script Filter" getting started guide for more info, and to see this in practice.
Item Variables
Individual item objects can have variables which are passed out of the Script Filter object if the associated result item is selected > in Alfred's results list. variables set within an item will override any JSON session variables of the same name.
It is also possible to add a variables object for each mod in the item object, allowing you to differentiate when a mod result is selected within your workflow. Note that when setting a variables object on a mod, this replaces the item variables, and doesn't inherit from them, allowing maximum flexibility.
When a mod doesn't contain a variables object, it will assume the item variables. To prevent this, add an empty variables object: "variables": {}.