Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(espanso): support custom path #13977

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

erics118
Copy link
Contributor

Description

Add a preference option to support custom location to espanso CLI.

Screencast

CleanShot 2567-08-11 at 23 43 01

Checklist

@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: espanso Issues related to the espanso extension labels Aug 12, 2024
@raycastbot
Copy link
Collaborator

raycastbot commented Aug 12, 2024

Thank you for your contribution! 🎉

🔔 @kud @nbbaier you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

You can expect an initial review within five business days.

Copy link
Contributor

@jfkisafk jfkisafk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor suggestions

@kud
Copy link
Contributor

kud commented Aug 13, 2024

Hey folks, I appreciate the help done here. Though, I'm not sure about that.

espanso is a shortcut here and must be in your $PATH. It does not matter if you use an Intel machine or an Apple Silicon one. I'm not sure it's the responsibility of Raycast or this extension to understand where the command exists.

I will look into this PR deeper soon.

@erics118
Copy link
Contributor Author

This is supposed to fix #13398. The problem there seems to be that for some reason, espanso isn't in the PATH that Raycast has access to. This PR fixes it by instead just using hardcoded defaults

@kud
Copy link
Contributor

kud commented Aug 14, 2024

I will read the code again, to see if it's an optional field, because I don't want that all users have to mention the path of espanso when it already works. If it's a custom field where people can override it, that's alright tho.

@kud
Copy link
Contributor

kud commented Aug 20, 2024

Will try to check this asap.

@pernielsentikaer
Copy link
Collaborator

Let me know your findings @kud, thanks for checking

@pernielsentikaer pernielsentikaer self-assigned this Aug 20, 2024
},
"scripts": {
"build": "ray build -e dist",
"dev": "ray develop",
"fix-lint": "ray lint --fix",
"lint": "ray lint",
"prepublishOnly": "echo \"\\n\\nIt seems like you are trying to publish the Raycast extension to npm.\\n\\nIf you did intend to publish it to npm, remove the \\`prepublishOnly\\` script and rerun \\`npm publish\\` again.\\nIf you wanted to publish it to the Raycast Store instead, use \\`npm run publish\\` instead.\\n\\n\" && exit 1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓Does it come from a new version of Raycast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from a newer version of the template that I copied over


export default async function main() {
try {
await $`espanso cmd disable`;
await showHUD("Espanso disable");
await espanso("cmd disable");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 I think I would like more a helper on espanso like

await $`${espansoCmd} cmd disable`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that using a function makes it less likely to have issues with typos, ie missing a space between } and cmd. I also did remove the dependency on zx and instead use the native exec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current way allows for only needing to import one function, rather than the path string and a function to execute the command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with the typo issue, tho, I'm happy to remove the zx dependency here to make it lighter. Tho, not sure I won't take it back if I need it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you tho change the name of the function like espansoShell or espansoCli , something like that?

@pernielsentikaer
Copy link
Collaborator

@erics118 could you see the comments from @kud

@erics118
Copy link
Contributor Author

Oops, forgot to push the commit I made three days ago. I've replied to the comments.

@pernielsentikaer
Copy link
Collaborator

Ah, so everything should be resolved 🙂

@kud can you check again 🙂


export default async function main() {
try {
await $`espanso cmd disable`;
await showHUD("Espanso disable");
await espanso("cmd disable");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with the typo issue, tho, I'm happy to remove the zx dependency here to make it lighter. Tho, not sure I won't take it back if I need it.


export default async function main() {
try {
await $`espanso cmd disable`;
await showHUD("Espanso disable");
await espanso("cmd disable");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you tho change the name of the function like espansoShell or espansoCli , something like that?

@kud
Copy link
Contributor

kud commented Sep 2, 2024

@erics118 Please check those comments 🙏

@erics118
Copy link
Contributor Author

erics118 commented Sep 3, 2024

I've renamed espanso to espansoCli

Comment on lines +3 to +15
import { exec } from "child_process";

function execAsync(command: string): Promise<{ stdout: string; stderr: string }> {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
reject(error);
return;
}
resolve({ stdout, stderr });
});
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like

import { exec } from "child_process";
import { promisify } from "util";

const execAsync = promisify(exec);

could be probably better.

Comment on lines +23 to +24
? "/opt/homebrew/bin/espanso"
: "/usr/local/bin/espanso";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could test first if it exists because not everyone installs it via homebrew.

Wonder if we could check first if the shortcut command espanso exists and once it does not exist, test first the preference and then the homebrew version.

@pernielsentikaer
Copy link
Collaborator

Could you check again @kud 🙂

@kud
Copy link
Contributor

kud commented Sep 6, 2024

The last two comments have not been resolved or discuted. @pernielsentikaer @erics118

@erics118
Copy link
Contributor Author

erics118 commented Sep 6, 2024

Sorry, I was working on it and had mistakenly resolved them before actually committing the code. I'll update later today

@pernielsentikaer
Copy link
Collaborator

Let me know if I can help you with anything

@kud
Copy link
Contributor

kud commented Sep 10, 2024

@pernielsentikaer For now, there is only one user who has an issue, and it's not even certain there's a way to fix it, but it's worth trying. If it takes too much time to resolve, I will fix my own suggestions. Thanks for asking!

@raycastbot
Copy link
Collaborator

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

@raycastbot raycastbot added the status: stalled Stalled due inactivity label Sep 24, 2024
@pernielsentikaer
Copy link
Collaborator

So we should just merge this one?

@raycastbot raycastbot removed the status: stalled Stalled due inactivity label Sep 25, 2024
@kud
Copy link
Contributor

kud commented Sep 25, 2024

@pernielsentikaer To be honest, I'm kind of against this PR because of a responsibility concern where this issue should be fixed by the user in their shell. I'm happy to accept it if it can help some users (how many?) to fix the issue by specifying the path of the Espanso CLI, but here we override the path of Espanso by default, which is not great because all the people who installed the app without Homebrew could have an issue now. So yeah, I'm not in the rush to merge it 😬

@kud
Copy link
Contributor

kud commented Sep 25, 2024

My question is why do we need to force it in the code? Is there a way that we could help users to fix their shell issue?

I know raycast uses its own shell or at least not the logged one. I'm happy to add a documentation to fix this path issue in the README.

@pernielsentikaer
Copy link
Collaborator

Did you resolve your question with the command from George on Slack

@kud
Copy link
Contributor

kud commented Oct 1, 2024

@pernielsentikaer I think I've got an idea yeah. Lemme work on that PR. 😌

@pernielsentikaer pernielsentikaer added the Dont close Won't be closed by stalebot label Oct 2, 2024
@pernielsentikaer pernielsentikaer removed the Dont close Won't be closed by stalebot label Mar 11, 2025
@pernielsentikaer
Copy link
Collaborator

Can we close this one?

@kud
Copy link
Contributor

kud commented Mar 11, 2025

Lemme double check.

@acicovic Do you still have the issue?

@acicovic
Copy link

I can confirm that I still have the issue. To work around this, I'm using Espanso's search bar outside of Raycast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension: espanso Issues related to the espanso extension extension fix / improvement Label for PRs with extension's fix improvements status: awaiting response from dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants