Question

I have a source code that runs perfectly fine on Ubuntu, it does some copumtations, and at some points it beeps like this

system("beep -f 400 -l 500");

On Ubuntu I had to do

apt-get install beep

However, I migrated to OpenSuse (not my choice) and now I get this message "sh: beep: command not found", as the command and package are obviously different.

Does anybody know hot to trigger the system beep sound and define the duration and frequency? I have been able to find only one way to change the parameters

setterm -bfreq 500 -blength 500

, but no way to actually trigger the system bell (beep). The following things don't work

echo ^G
echo -e "\a"

PS - the system Bell is enabled at Configure Desktop -> Application and System Notifications -> System Bell and you can actually play with this

Was it helpful?

Solution

So, I did what @fvu proposed.

However, one needs to have sudo rights, to do so, otherwise (e.g. at my work-place we don't have sudo rights) there is this output message

Could not open /dev/tty0 or /dev/vc/0 for writing open: No such file or directory

In this case, you should:

sudo chmod 4755 /usr/bin/beep

as proposed here

OTHER TIPS

I noticed that on my OpenSuse 12.3 system, the bell is working in xterm or gnome-terminal, but not in konsole or xfce4-terminal. If the same applies to your system, then maybe a work-around could be creating a shell script called "beep" which calls xterm and rings the bell:

#!/bin/sh
xterm -e "echo -e '\a'; sleep 1"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top