Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Espanso doesn't support replacements which include delays
- # A solution is to ignore Espanso's own replace and use another tool to inject characters
- # Similar methods are available for Windows PowerShell using e.g.:
- # (New-Object -ComObject wscript.shell).SendKeys
- # Snippet to inject text using xdotool
- - trigger: ":xd"
- replace: "{{output}}" # Redundant placeholder
- vars:
- - name: output
- type: shell
- params:
- cmd: |
- # Remove trigger characters
- xdotool key BackSpace BackSpace BackSpace
- xdotool type "Some text"
- xdotool key KP_Enter
- sleep 1.5
- xdotool type "Some more text"
- # Supply dummy characters for Espanso to remove
- xdotool key Return type ":xd"
- # Snippet to inject text using Python
- # https://pynput.readthedocs.io/en/latest/keyboard.html#controlling-the-keyboard
- - trigger: ":pd"
- replace: "{{output}}" # Redundant placeholder
- vars:
- - name: output
- type: script
- params:
- args:
- - python
- - -c
- - |
- import time
- from pynput.keyboard import Controller, Key
- keyboard = Controller()
- # Remove trigger characters (simulate pressing BackSpace three times)
- for _ in ":pd": keyboard.tap(Key.backspace)
- keyboard.type("Some text")
- keyboard.tap(Key.enter)
- time.sleep(1.5)
- keyboard.type("Some more text")
- # Supply dummy characters for Espanso to remove
- keyboard.type(":pd")
Add Comment
Please, Sign In to add comment