Booleans/checkboxes in forms
Description
I would like a feature that offers the ability to have checkboxes to indicate whether or not to include certain parts of an expansion in a form. For instance, a form dialog would look like This is a wonderful day( [ ] because it's a weekend! ) with the part in (parens) highlighted, and the [X] indicates a checkbox. If checked, would output: "It's a wonderful day because it's a weekend!" but if unchecked would just output "It's a wonderful day" Personally, I would have the YAML look like: form: It's a wonderful day [[weekend]] form_fields: weekend: value: because it's a weekend! checked: true // default to checked, false would be unchecked
Motivation
I use Espanso in my role in email support for a medical software company. I have well over 300 expansions over more than a dozen files, and many of them have parts that only need to be included sometimes (such as if a user is a provider rather than a biller) and have to manually edit the replaced text. As our system uses a slow web-based case management system that requires taking my hands off of the keyboard to interact with, this small edit is very disruptive. Being able to turn parts of my email on and off by tabbing to a checkbox and turning it on and off would allow me to increase my productivity, and would avoid having to have two replacements that are identical other than a couple of words which can result in one being edited and the other being missed, violating SPOT principals.
Alternatives
No response
Have you tried building it? Or would you like it?
- [ ] I'd be willing to contribute this feature to Espanso myself.
Some conditional processing in Espanso would indeed be useful.
Are you wishing for a global checkbox option to affect the responses to multiple triggers? Otherwise, one would use a choice extension (+/- labels for weekday/weekend) for the example you suggest?
- trigger: :test
replace: '{{output}}'
vars:
- name: output
type: choice
params:
values:
- This is a wonderful day.
- This is a wonderful day because it's a weekend!
Or script it so that the output is automatic:
- trigger: ":daymsg"
replace: "{{output}}"
vars:
- name: output
type: script
params:
args:
- python
- -c
- |
import datetime
if datetime.datetime.today().weekday()>=5:
print("This is a wonderful day because it's a weekend!")
else:
print("This is a wonderful day.")
This was a basic example. In my case, generally my replies are multiple paragraphs, but there may be a small part that is included sometimes. A more accurate example would be:
lorem ipsum dolor. lorem blah blah....
blah blah {this text only if the user is a VIP} yada yada...
{this paragraph prints if the user has been with us over 18 months}
foo {bar but only for users with service X enabled} baz
closing
Obviously this would not work well with choice extensions, I wouldn't think. Maybe it could: I'll play with it, but there was a checkbox to toggle parts of the expansion in Blaze that I am imagining here. Scripting is off the table: I cannot install scripting languages due to company security policies. I'm honestly surprised I was able to get espanso installed, and this is only using the portable version.
On Sun, Oct 19, 2025 at 5:53 PM Stephen Meech @.***> wrote:
smeech left a comment (espanso/espanso#2543) https://github.com/espanso/espanso/issues/2543#issuecomment-3420026866
Some conditional processing in Espanso would indeed be useful.
Are you wishing for a global checkbox option to affect the responses to multiple triggers? Otherwise, one would use a choice extension for the example you suggest?
- trigger: :test replace: '{{output}}' vars:
- name: output type: choice params: values: - This is a wonderful day. - This is a wonderful day because it's a weekend!
Or script it so that the output is automatic:
- trigger: ":daymsg" replace: "{{output}}" vars:
- name: output type: script params: args: - python - -c - | import datetime if datetime.datetime.today().weekday()>=5: print("This is a wonderful day because it's a weekend!") else: print("This is a wonderful day.")
— Reply to this email directly, view it on GitHub https://github.com/espanso/espanso/issues/2543#issuecomment-3420026866, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABCBRDWCLOQSC3RNONE7H33YQI77AVCNFSM6AAAAACJTVSIACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTIMRQGAZDMOBWGY . You are receiving this because you authored the thread.Message ID: @.***>
I cannot install scripting languages
Would you be able to use the default shell for scripting? That would avoid the need to install anything more.
I think this is likely to be a low-priority enhancement, so am currently considering workarounds.
I can envisage some files of global variables that could be toggled on and off to provide the necessary optional phrases, with placeholders in the triggers themselves which would return either a single space or phrases, according to the requirements. Once the files exist, their toggling consists of prefixing or not the files with an underscore (thus triggering an Espanso reload), but that would require a shell script, although it could be triggered from an Espanso expansion itself.
Such a script would simply:
- Delete pre-existing
VIP.yml,18month.yml,serviceX.yml - Copy
_VIP.yml,_18month_yml, and/or_servicex.ymlas required toVIP.yml,18month.yml,serviceX.yml - Empty (single-space) variables would be contained in a default file which Espanso loads first alphabetically, to be overwritten by any of the above.