[go: nahoru, domu]

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

[Bug]: shell.beep() doesn't do anything on Linux (unless Electron was launched from a terminal) #40625

Open
3 tasks done
DeeDeeG opened this issue Nov 28, 2023 · 5 comments
Open
3 tasks done
Labels
27-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/linux

Comments

@DeeDeeG
Copy link
Contributor
DeeDeeG commented Nov 28, 2023

Preflight Checklist

Electron Version

27.1.2

What operating system are you using?

Ubuntu

Operating System Version

Tested on Ubuntu 22.04 and 23.10, Fedora 39 (all via LiveUSB session)

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

shell.beep() should always produce a "beep" or "alert" noise.

Actual Behavior

On Linux, shell.beep() produces no sound or alert, if Electron was launched any way other than from a terminal.

Testcase Gist URL

https://gist.github.com/DeeDeeG/d28093106b3f5a747cf925d00ae67357

Additional Information

On Linux, If Electron is launched from a terminal, the terminal app handles the beep, and an audible beep does play, assuming the user's terminal preferences allow it -- see "alert" or "bell" settings in your terminal app of choice.

On Windows and macOS, shell.beep() plays an audible noise regardless of whether Electron was launched from a terminal or otherwise.

@mlaurencin mlaurencin added platform/linux has-repro-gist Issue can be reproduced with code at https://gist.github.com/ 27-x-y labels Nov 29, 2023
@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@piotrpdev
Copy link
Contributor

I'm not sure if there is a good solution for this. Here is the code that produces the beep on Linux:

void Beep() {
// echo '\a' > /dev/console
FILE* fp = fopen("/dev/console", "a");
if (fp == nullptr) {
fp = fopen("/dev/tty", "a");
}
if (fp != nullptr) {
fprintf(fp, "\a");
fclose(fp);
}
}

The code tries to:

Apart from those methods, the only thing I can think of doing is creating and playing a beep using asoundlib.h since the linux build uses ALSA development dependencies.

$ sudo apt-get install build-essential clang libdbus-1-dev libgtk-3-dev \
libnotify-dev libasound2-dev libcap-dev \

I'm not sure if doing all of that is worth it just to get a beep though.


Meanwhile, Windows and Mac call their respective built-in beep functions :/

void Beep() {
MessageBeep(MB_OK);
}

void Beep() {
NSBeep();
}

@DeeDeeG
Copy link
Contributor Author
DeeDeeG commented Mar 22, 2024

Thanks for that info. I somewhat suspected there was no one neat API for this to address "all of Linux". But the info you linked definitely backs that up.

I suppose it would be okay to close this as "not planned" or something like that, since it may not be very doable? Hmm.

[EDIT: Speaking as just a random person who uses Electron. I must have contributed some small docs change at some point, I'm labeled as a "Contributor" but I don't really have any status with Electron project different than any other regular end-user.]

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@DeeDeeG
Copy link
Contributor Author
DeeDeeG commented Jun 28, 2024

Technically still applies, so "bump".

I dunno if Electron folks wanna go the ALSA asoundlib route that was mentioned just above.

I'm personally not totally invested in this topic, I filed it after someone asked about it who uses the project I do work on. But, yeah. Still relevant, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
27-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/linux
Projects
No open projects
Status: No status
Status: 👍 Does Not Block Stable
Development

No branches or pull requests

3 participants