# How to make console beep?



## Erratus (Mar 5, 2010)

Backspace at empty prompt in console makes PC-speeker "beep!", also hitting 'Control-G'.
Doing this in KDE-Konsole generates a sound. So far this behaviour is expected. 

But all my attempts generating a console-beep in scripts fail.

Doing this


```
# echo "^G^G^G"
^G^G^G
```

just makes no noise on my amd64. Found a lot of stuff how to disable bell, but nothing how to make the bell ring.


----------



## sixtydoses (Mar 5, 2010)

Any chance you're referring to hw.syscons.bell?


----------



## Erratus (Mar 5, 2010)

```
# sysctl -a | grep hw.syscons.bell
hw.syscons.bell: 1
```


----------



## varda (Mar 5, 2010)

```
echo -e "\007"
```
Also you can enable speaker device in kernel or simply load it

```
kldload speaker
```
Then you can use it this way

```
echo "BP" > /dev/speaker
echo "SO4L16G>L8C." > /dev/speaker
```
See man speaker


----------



## Erratus (Mar 5, 2010)

```
# echo -e "\007"
-e \007
```
does not work with tcsh. Using bash it works. So how could this be done in csh scripts?


----------



## Erratus (Mar 5, 2010)

Maybe I found the reason for the bash/tcsh difference, but I'm not sure about

```
> bindkey | grep "\^G" -C1
"^F"           ->  forward-char
"^G"           ->  not defined
"^H"           ->  backward-delete-char
```
Now I'm struggling for the proper use of bindkey to make ^G bound to bell. If someone knows how to do that, please jump in.


----------



## varda (Mar 6, 2010)

Sorry  I never used csh/tcsh/bash during the last dozen years.


----------



## Rulus (Nov 29, 2013)

If someone is still interested, printf instead of echo works for me (in csh/tcsh), e.g. `echo -e "\007"` prints _-e \007_, but `printf "\007"` makes the console beep. Same with `printf "\a"`. As far as I know, `printf "^G"` doesn't work.

Hope it helps.


----------



## hselasky@ (Nov 15, 2021)

man 1 beep()


----------



## grahamperrin@ (Nov 21, 2021)

I see the bell: 






– but I don't hear the bell. I found relevant preferences for Konsole, none set to play a sound:


– and only one of the listings has a sound: 


– _Oxygen-Sys-App-Message.ogg_


```
% pkg provides Oxygen-Sys-App-Message.ogg
Name    : plasma5-oxygen-5.23.2
Desc    : Plasma5 Oxygen style
Repo    : FreeBSD
Filename: usr/local/share/sounds/Oxygen-Sys-App-Message.ogg
%
```


----------



## Erichans (Dec 22, 2021)

On the command line, does the <backspace>, <del> or <tab> key produce an audible sound?


----------



## hselasky@ (Dec 22, 2021)

FYI: In FreeBSD-14 the console bell is a devd event. You may want to see if you get something there first.


----------



## Andriy (Dec 22, 2021)

grahamperrin said:


> I found relevant preferences for Konsole, none set to play a sound:


There are also some settings under Accessibility -> Bell.
I would never think that "bell" / beeper settings belong there.


----------



## grahamperrin@ (Dec 22, 2021)

Thanks. Already enabled: 



Maybe I'm simply too deaf for it. I'll experiment with the visual bell.


----------



## grahamperrin@ (Dec 22, 2021)

Erichans said:


> On the command line, does the <backspace>, <del> or <tab> key produce an audible sound?



No, however there's the bell icon in the tab. 

Visual bell enabled, but no inversion of the screen. This smells like maybe a bug in or around Plasma, I might mention it in IRC.


----------



## Andriy (Dec 22, 2021)

grahamperrin said:


> No, however there's the bell icon in the tab.
> 
> Visual bell enabled, but no inversion of the screen. This smells like maybe a bug in or around Plasma, I might mention it in IRC.


Can you get the bell / beep in a regular (non-X) console?
Recently there was a change that disabled the beeper by default.
Apparently it annoys more people than there are people who need / like it.
See hw.syscons.bell and kern.vt.enable_bell for sc and vt respectively.


----------



## grahamperrin@ (Dec 22, 2021)

```
root@mowa219-gjp4-8570p-freebsd:~ # sysctl hw.syscons.bell kern.vt.enable_bell
hw.syscons.bell: 1
kern.vt.enable_bell: 0
root@mowa219-gjp4-8570p-freebsd:~ # sysctl kern.vt.enable_bell=1
kern.vt.enable_bell: 0 -> 1
root@mowa219-gjp4-8570p-freebsd:~ # uname -KU
1400043 1400043
root@mowa219-gjp4-8570p-freebsd:~ # uname -a
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #116 main-n251146-d109559ddbf: Mon Nov 29 14:34:59 GMT 2021     root@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG  amd64
root@mowa219-gjp4-8570p-freebsd:~ #
```

Nothing audible at ttyv1 following the change, should I reboot for the change to take effect?


----------



## Vull (Dec 22, 2021)

For Konsole,
  Settings > Edit Current Profile > General > Terminal bell mode: System Bell


```
len@klatest:/usr/home/len $ printf '\007'
len@klatest:/usr/home/len $ pkg info -E plasma5-plasma
plasma5-plasma-5.23.4
len@klatest:/usr/home/len $ freebsd-version
13.0-RELEASE-p5
len@klatest:/usr/home/len $ sysctl hw.syscons.bell
hw.syscons.bell: 1
len@klatest:/usr/home/len $ sysctl kern.vt.enable_bell
kern.vt.enable_bell: 1
len@klatest:/usr/home/len $
```


----------



## grahamperrin@ (Dec 22, 2021)

Vull said:


> … Terminal bell mode: System Bell



Success! (In Konsole.) Thanks. 

As a bonus, I'll probably no longer have the (slightly annoying) notifications "Bell in Konsole" or words to that effect. The penny just dropped.


----------

