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

cli: add sound when awaiting ledger interaction #34

Merged
merged 2 commits into from
Dec 5, 2024
Merged

Conversation

juliangruber
Copy link
Member

Since it's a long running script, notify the operator that a ledger interaction is necessary

@juliangruber juliangruber requested a review from bajtos December 2, 2024 11:37
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

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

The changes SGTM, with two comments to consider:

  • Personally, I configured my terminal to turn ANSI beep sequence into a screen flash, so this is probably not going to work for me. (I didn't check, TBH.)
  • In the past, I had a good experience using say, a built-in macOS CLI utility. That may not be portable to Linux/Windows, though.

@juliangruber
Copy link
Member Author

The changes SGTM, with two comments to consider:

  • Personally, I configured my terminal to turn ANSI beep sequence into a screen flash, so this is probably not going to work for me. (I didn't check, TBH.)

Beeper uses this:

process.stdout.write('\u0007');

Can you try if that creates a sound for you? For me it plays a sound and makes the screen flash.

  • In the past, I had a good experience using say, a built-in macOS CLI utility. That may not be portable to Linux/Windows, though.

I'm also using that in my shall, eg node script.js && say "done", but that doesn't work here (unless we add something like node script.js --on-ledger="say \"attention\""). I could look into a say node module (for a portable solution), or would you suggest to just spawn that utility?

@bajtos
Copy link
Member

bajtos commented Dec 5, 2024

The changes SGTM, with two comments to consider:

  • Personally, I configured my terminal to turn ANSI beep sequence into a screen flash, so this is probably not going to work for me. (I didn't check, TBH.)

Beeper uses this:

process.stdout.write('\u0007');

Can you try if that creates a sound for you? For me it plays a sound and makes the screen flash.

node -e "process.stdout.write('\u0007');"

For me, this flashes the screen, but there is no sound.

  • In the past, I had a good experience using say, a built-in macOS CLI utility. That may not be portable to Linux/Windows, though.

I'm also using that in my shall, eg node script.js && say "done", but that doesn't work here (unless we add something like node script.js --on-ledger="say \"attention\""). I could look into a say node module (for a portable solution), or would you suggest to just spawn that utility?

IDK, TBH. I don't want us to spend too much time on this, it does not seem to worth the effort.

What is the simplest solution?

How about we execute the say CLI when running on macOS and fall back to beeper on other platforms? (We can use your write snippet directly to avoid an extra dependency.)

@bajtos
Copy link
Member

bajtos commented Dec 5, 2024

We can also land this PR as-is and improve it iteratively later.

@juliangruber
Copy link
Member Author

Up to you! I'm fine with the solution as is because it does everything I need. I propose you follow up with a say implementation if you need it?

@juliangruber
Copy link
Member Author

I would say it's fair to assume that a shell ascii beep works, and I think your setup diverges from the norm, therefore I think following up with say best sits with you

@juliangruber juliangruber merged commit 3167b3e into main Dec 5, 2024
6 checks passed
@juliangruber juliangruber deleted the add/beeper branch December 5, 2024 10:19
@bajtos
Copy link
Member

bajtos commented Dec 5, 2024

SGTM 👌🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants