Open DevGuyRash opened 3 months ago
My apologies, but I'm not sure if I understand the problem.
You're currently using backend: auto
, which will use inject
for short expansions, and switch to clipboard
for those longer than the number of characters specified in your clipboard_threshold: 100
setting. If clipboard
doesn't work in that situation, nothing will be returned.
If the routine works using the inject
backend, simply use it. You probably need an app-specific configuration for all expansions in that particular program, or, in the unlikely situation where this is the only expansion failing, add the line force_mode: keys
to the regex:
, replace:
pair.
The issue with inject
for long form content is that on many platforms when a newline is injected it causes the form to submit. For example, when prompting on chatgpt or on other chat-oriented applications. It also creates issues in IDEs when programming due to the settings of the IDEs which try to insert the matching delimiter characters. It is also much slower.
App-specific configurations are unfortunately unsupported on wayland. I will try the force_mode
setting later today. This issue is specifically on wayland and is a bug with the clipboard. To better establish the issue:
Lets say I have an espanso match that uses the shell
extension and simply outputs whatever the cmd
is. Given the following file and match, there are two ways to output the file's contents that will work:
foo.txt
:
Hello, World!
bar.yml
:
- regex: ':file'
replace: "{{replace}}"
vars:
- name: replace
type: shell
params:
cmd: cat foo.txt
cmd
Given this file, here are the outcomes of the cmd
:
# This original one would fail to output anything at all
cat foo.txt
# This one would output the file correctly and the clipboard would work
echo -n "prefix:";
cat foo.txt;
Unless something is output prior to a cat
, it will fail to output anything. The logs will show that stdout
contains the contents of the file even upon failure.
replace
The alternative is to leave the match the same and add a prefix character (even just a single one). The file will then also correctly output its contents:
- regex: ':file'
replace: "a{{replace}}" # The letter 'a' was added. It has to be before
vars:
- name: replace
type: shell
params:
cmd: cat foo.txt
The overall issue here is that the clipboard only seems to work on wayland when there is a prefix character to initialize it.
Dear @DevGuyRash
Apologies for hijacking this thread, but I've been reviewing your "spell-check" PR at https://github.com/espanso/hub/pull/89, and raised a number of issues that need fixing before we can merge.
I don't know if you've been notified of these (and it would be interesting to hear, as you're not the only person who hasn't responded!), so thought I'd try and make direct contact.
Let me know if you need any help with the amendments. Whilst I could probably make them, I think it's preferable if it's your own work.
With best wishes,
Description
Code
Issue
When running in a wayland environment with the backend set to
clipboard
, espanso does not output anything when usingcat
as part of theshell
extension. I have even created a simpler version of this that only runscat
on a file I created specifically for this. Both that simple version and this version work when run in terminal line by line.I have found that if you add even a single letter before
{{find_file}}
in thereplace
, or if you echo out a single letter prior to trying tocat
, then it will work as expected.After checking the logs, even though nothing is produced whenever it tries to
cat
, the contents of the file actually do still show up in the logs understdout
. They are just not being pasted into wherever my cursor is.This script works fine when the backend is
inject
and onx11
Settings
Espanso Settings
PC Settings
Steps to reproduce
shell
extension and have it try tocat
a file with no additional output other than thecat
.Expected behavior
It should paste the contents of the file into where my cursor is
Screenshots
No response
Logs
Your environment
Self-service