Actions
Actions perform tasks and updates on an Alfred UI and are are usually the result of events.
{
"type": "button",
"text": "Press Me!",
"events": [
{
"triggers": "actioned",
"action": {
"type": "script",
"src": "./scripts/fruits-filter.zsh",
"args": [
"lettuce",
"banana",
"{value:basket_list.selected.name}",
"{var:current_produce}"
]
}
}
]
}
In the above we have a button which when triggered runs the script at ./scripts/fruits-filter.zsh (relative to the .alfredui root folder) with four arguments: lettuce and banana are literal values while {value:} and {var:} are placeholders which are evaluated when the action runs.
action Object
The action object configures a single action.
- type
- ENUM
- Required
The type of action to run.
| Value | Description |
|---|---|
"log" |
Log based on the log configuration. |
"script" |
Run a script. The output of the script will be parsed as JSON actions. |
"json" |
Run JSON actions. |
"function" |
Run a function directly on a component by id. |
- src
- STRING | OBJECT
- Required
The contextual source to implement this action, depending on type.
type Value |
src Description |
|---|---|
"log" |
Ignored. |
"script" |
The script's path. |
"json" |
The JSON actions, or the path to a json file. |
"function" |
The id of the component to run the function on. |
- args
- STRING | ARRAY
The arguments for this action, which can take {value:self.param}, {value:componentid.param}, {data:datavalue} in addition to arbitrary strings and {var:variablename}.
type Value |
args Description |
|---|---|
"log" |
Logged at the "info" level. |
"script" |
Arguments passed to the script src. |
"json" |
Ignored. |
"function" |
Names of the functions to run on the src component. |
NoteIf a placeholder is unable to be resolved, an empty string will be returned.
Dictionaries will be converted to JSON. Arrays will be converted to JSON unless
flattenarrayargsis set. These are resolved when the action is triggered, and before the action is processed.
- variables
- OBJECT
Variables for this action, which can take {value:self.param} and {value:componentid.param} in addition to arbitrary strings and {var:variablename}.
These are resolved when the action is triggered, and before the action is processed.