fix: beep on Ubuntu (#16350)
beeps on Linux are made by writing BEL to /dev/console, which requires elevated permissions on Ubuntu. So if opening /dev/console fails, fall back to /dev/tty.
This commit is contained in:
parent
d0ae89befa
commit
52852b963a
1 changed files with 8 additions and 5 deletions
|
@ -140,11 +140,14 @@ bool MoveItemToTrash(const base::FilePath& full_path) {
|
||||||
|
|
||||||
void Beep() {
|
void Beep() {
|
||||||
// echo '\a' > /dev/console
|
// echo '\a' > /dev/console
|
||||||
FILE* console = fopen("/dev/console", "r");
|
FILE* fp = fopen("/dev/console", "a");
|
||||||
if (console == NULL)
|
if (fp == nullptr) {
|
||||||
return;
|
fp = fopen("/dev/tty", "a");
|
||||||
fprintf(console, "\a");
|
}
|
||||||
fclose(console);
|
if (fp != nullptr) {
|
||||||
|
fprintf(fp, "\a");
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetDesktopName(std::string* setme) {
|
bool GetDesktopName(std::string* setme) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue