Live data from Hacker News

Show HN: Espanso: detect a typed keyword and replace it while you're typing

espanso.org

51–60 of 77 posts

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#51
Bit of a plug, but if you crave for that, and more, you can use AutoKey on Linux (not AutoHotKey which is Windows only): https://github.com/autokey/autokey

It will let you bind custom Python scripts to any mouse/keyboard sequence, including words on the fly. It can trigger word replacements just like Espanso (I use it to fill in emails, dates, addresses, timestamps et phone numbers), and of course, Python being Python, it lets you do a lot more.

The UI is probably not as good as Espanso's, and it may be harder to use (you need to script). On the other hand, it provides an API for prompting you with UI to select dates, files, input, etc., has timers and the whole Python 3 stdlib.

Some nice stuff I do with it:

- typing $email/$ phone present me with a list of email addresses/phone num (I have a lot of them) to insert one. Prevents typo. By pass web form limitations.

- $now and $date does something similar with dates (listing of various formats for the current date and a calendar). Very handy for documents and file name. Most of them don't have automated fields set up.

- $paste paste the clip board content, by passing any UI preventing me to do so, and screen/tmux limitations.

- I'm a heavy dynalist users (dynalist.io/) I love this software, but it lacks a lot of features, which are easy to add with AutoKey: just make a macro that inputs a serie of actions.

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#52
post #45

Earlier quoted context omitted.

I'm sorry you experienced this problem! How many snippets were you using? AHK is indeed a wonderful tool, and because it only supports Windows, it can apply some optimizations that are not available on other platforms. I'm currently rewriting the core, so things might get a bit faster in the future :)

I don't use many snippets, probably less than a hundred. Just tried it again. Not as slow as I remember, the syntax is also cleaner than AHK. Switching to it now :)

Thanks! If you have any feedback or experience any problem, feel free to open an issue on GitHub :)

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#53
post #44

Earlier quoted context omitted.

You're welcome! :) You might also enjoy the dad-jokes package: https://hub.espanso.org/packages/dadjoke/

Love it! It turns out espanso is in the AUR for Arch. I've just filled kate with dadjokes which isn't as sick as it sounds!

Thanks! The AUR package is all thanks to our wonderful maintainer Scrumplex [1].

[1]: https://scrumplex.net/

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#54
post #46

(Author here) Feel free to ask any question, I'll be happy to answer them :)

I seem to have found a bug. When I use the default match ":espanso" on my terminal (Kitty) it gets expanded to "hi there1", while I expect "Hi there!". Seems to work fine on Firefox. Edit: Seems like it's an issue with shifted characters? When I type any trigger and erase, for example ":espanso", I expect the first character to be a colon (:) but instead I get a semi-colon (;). Weird.

Thanks for reporting this issue! I'm working on a patch that should solve this problem. In the meanwhile, can you try adding:

backend: Clipboard

on your default.yml file and see if that helps?

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#56
post #34

Earlier quoted context omitted.

Thanks for the response, but unless I take the time to literally go to your entire repo and make sure you aren't doing anything weird, I'm not installing this thing.

If you're in a position to use this program[0], you're already taking the same risk by running most other programs on your machine - they also have access to your keypresses. [0]: The only real reason you wouldn't be is if you're on a non-X Linux desktop. Wayland prevents this kind of program by design.

Fun fact, Wayland support is the most requested feature [1] and I think it's possible, although we will need to go deeper in the stack and exploit EVDEV

[1]: https://github.com/federico-terzi/espanso/issues/287

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#57

Bit of a plug, but if you crave for that, and more, you can use AutoKey on Linux (not AutoHotKey which is Windows only): https://github.com/autokey/autokey It will let you bind custom Python scripts to any mouse/keyboard sequence, including words on the fly. It can trigger word replacements just like Espanso (I use it to fill in emails, dates, addresses, timestamps et phone numbers), and of course, Python being Pytho…

Hey, AutoKey is awesome indeed! I've used it myself for a while before developing espanso. In fact, I went through the code-base multiple times to understand how it could be so fast. I learned plenty of things about how the X server works thanks to you :)

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#58

Bit of a plug, but if you crave for that, and more, you can use AutoKey on Linux (not AutoHotKey which is Windows only): https://github.com/autokey/autokey It will let you bind custom Python scripts to any mouse/keyboard sequence, including words on the fly. It can trigger word replacements just like Espanso (I use it to fill in emails, dates, addresses, timestamps et phone numbers), and of course, Python being Pytho…

Hey, AutoKey is awesome indeed! I've used it myself for a while before developing espanso. In fact, I went through the code-base multiple times to understand how it could be so fast. I learned plenty of things about how the X server works thanks to you :)

Thanks for making your tool opens ource.

Do you plan to add scripting capabilities to Espanso or do you prefer to focus on the current use case ?

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#59
I have a simple custom solution that works well for me. Snippets are just files in a directory. The filename is the snippet name. If the file is executable, it uses whatever is returned from running it. You can use zenity [0] to create forms or run rofi/dmenu to select "arguments" in those scripts.

It uses `rofi` and `xdotool`:

  #!/bin/bash
  SNIPPET_DIR="${HOME}/.config/snipex"
  DMENU="rofi -dmenu -b -p Snippet:"
  XSEL="/usr/bin/xsel --clipboard --input"
  SNIPPET=$(ls -1 "${SNIPPET_DIR}" | ${DMENU})
  FILE="${SNIPPET_DIR}/${SNIPPET}"
  
  STRIP_NEWLINE="head -c -1"
  
  if [ -x "${FILE}" ]; then
    # snippet is executable -> run it and copy the result
    ${FILE} | ${STRIP_NEWLINE} | ${XSEL}
  elif [ -f "${FILE}" ]; then
    # copy the contents of the file
    ${STRIP_NEWLINE} ${FILE} | ${XSEL}
  else
    # clean clipboard
    echo "" | ${XSEL}
  fi
  
  xdotool key --clearmodifiers "Shift+Insert"
edit: and I have an xbindkeys config to run this script when I press Meta+,

[0]: https://help.gnome.org/users/zenity/stable/forms.html.en

Re: Show HN: Espanso: detect a typed keyword and replace it while you're typing

#60

Earlier quoted context omitted.

If you're in a position to use this program[0], you're already taking the same risk by running most other programs on your machine - they also have access to your keypresses. [0]: The only real reason you wouldn't be is if you're on a non-X Linux desktop. Wayland prevents this kind of program by design.

Fun fact, Wayland support is the most requested feature [1] and I think it's possible, although we will need to go deeper in the stack and exploit EVDEV [1]: https://github.com/federico-terzi/espanso/issues/287

A nice technical writeup! The daemon approach sounds particularly promising. Have you also thought about a Wayland protocol extension? espanso is not the only program that will want total keyboard access, and it's one of the last big obstacles for a lot of X11 users.
Post reply on HN