Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A Python script to invoke `espanso match exec -t <trigger>`, which gets around
- # Espanso trying to delete the trigger characters (which don't exist when called
- # in this manner) by injecting the characters first.
- # An alternative to using: `xdotool sleep 0.2 type <trigger>`
- # Either can be attached to a system hotkey.
- #!/usr/bin/env python3
- import subprocess, sys, time
- from pynput.keyboard import Controller, Key
- # Check if a command-line argument is provided
- if len(sys.argv) != 2:
- print("Usage: python3 trigger_espanso.py <word>")
- sys.exit(1)
- else:
- word = sys.argv[1]
- # Create an instance of the keyboard controller
- keyboard = Controller()
- # Type the provided word into the active window
- keyboard.type(word)
- # Run the Espanso command to trigger the match with the provided word
- command = f"espanso match exec -t {word}"
- subprocess.run(command, shell=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement