Skip to content

Instantly share code, notes, and snippets.

@atika
Last active September 25, 2023 19:01
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save atika/dc2de3f8813d9919485761347b200d61 to your computer and use it in GitHub Desktop.
Save atika/dc2de3f8813d9919485761347b200d61 to your computer and use it in GitHub Desktop.
Text field and options dropdown for espanso (macOS only)

Simple prompt for espanso https://espanso.org/ on macOS

For the time being, espanso does not come with a graphical user interface, in the meanwhile you can use this workaround to prompt for text or select result in a list, on macOS.

Create a folder scripts in the espanso preferences folder and copy these files: /Users/<username>/Preferences/espanso/scripts/.

You can also copy Pashua app app into this folder.

espanso popup demo

Usage

- trigger: ":test"
  replace: "Bonjour {{genre}} {{nom}}, vous aimez {{activity}}."
  vars:
    - name: genre
      type: shell
      params:
        cmd: "$CONFIG/scripts/select.sh -l Genre -o \"Mr:Mme:Melle\""
        trim: true
    - name: nom
      type: shell
      params:
        cmd: "$CONFIG/scripts/textfield.sh -l \"Votre prénom\" -p \"John Snow\""
        trim: true
    - name: activity
      type: shell
      params:
        cmd: "$CONFIG/scripts/select.sh -l \"Activité préférée:\" -o \"dormir sous les étoiles:faire une ballade à cheval:danser sous la pluie\""
        trim: true

The $CONFIG variable here has been added to the launch agent as an environment variable: ~/Library/LaunchAgents/com.federicoterzi.espanso.plist

<dict>
  <key>EnvironmentVariables</key>
  <dict>
    <key>CONFIG</key>
    <string>/Users/<username>/Library/Preferences/espanso</string>
  </dict>
  ...
</dict>
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

@trolologuy
Copy link

trolologuy commented Oct 21, 2020

I noticed a few imprecisions:

  • On Cataline the path is: /Users/<username>/Library/Preferences/espanso/scripts.
  • It requires running chmod +x *.sh on the scripts.
  • For this to work, it is required to copy Pashua into this folder. I think that You can also copy Pashua app app into this folder. should be changed to It is required to copy Pashua into this folder.

Thanks for the great work though ! 👍

@emmettrn
Copy link

emmettrn commented Aug 1, 2022

here is the git hub for the Pashua app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment