You can set variables in Alfred by writing to stdout using a special JSON format. It would be handy if alfy.output
supported this, perhaps in a special variables
key:
alfy.output([
{ title: 'Google', arg: 'https://www.google.com', variables: { browser: 'Chrome' },
{ title: 'Mozilla', arg: 'https://www.mozilla.org', variables: { browser: 'Firefox' } }
])
Or as a second argument:
// backwards compatible, but less elegant
alfy.output([
{ title: 'Google', arg: 'https://www.google.com' },
{ title: 'Mozilla', arg: 'https://www.mozilla.org' }
], [
{ browser: 'Chrome' },
{ browser: 'Firefox' }
])
I'm happy to write a pull request if this seems worthwhile.
The format for emitting variables isn't complicated, but life would be easier if Alfy handled it.
// The root `alfredworkflow` key is required.
// Without it, Alfred will pass the object to the next node in the workflow like normal.
{
"alfredworkflow": {
"arg": "https://www.google.com",
"variables": {"browser": "Chrome"}
}
}
// `arg` is a stringified `alfredworkflow` object
{
"items": [{
"title": "Google",
"arg": "{\"alfredworkflow\": {\"arg\": \"https://www.google.com\", \"variables\": {\"browser\": \"Chrome\"}}}"
}]
}
Note, you can access Alfred variables through the environment:
const browser = process.env.browser
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too