PC speaker

About the PC speaker
The PC Speaker is more commonly referred to the speaker located on the motherboard. Nowadays this speaker is usually a simple piezoelectric speaker, with the piezoelectric speaker providing just enough speaker hardware to distinguish simple frequency and tones of beeps. Beeps usually occur on error, but can be customized as this article will document.

PC speaker kernel driver
Make sure your motherboard has two pins for the PC speaker, as well as being connected to a small speaker or piezoelectric speaker.

Build the Linux kernel module, named INPUT_PCSPKR, located within the folder architecture of Drivers > Input > Miscellaneous devices folder of menuconfig.

NOTE: It is common most users finding an easy way of disabling this so-called annoying device, by simply black listing the module within the /etc/modprobe.d/blacklist.conf, so ensure the loading of this module is not inhibited by such configurations.

PC Speaker configuration files and settings
Activation of the PC Speaker after ensuring the module is either built statically linked within the kernel or loaded, also include several settings are activated.

Util-Linux utility
While within the Linux console or terminal, use the following:

XOrg XSet utility
While within X11/Xorg, use the following.

Query current XSet options:

For users of the old PC keyboards having a speaker, users can easily activate a typewriting sound effect after each key press by doing:

Should show "key click percent: 100", for key clicks being activated.

GNU screen
By default, GNU Screen enabled audible bell style, unless visual style is activated. So disable visual style:

From within GNU Screen, 'CTRL-a CTRL-g' can switch visual or audible bell styles.

Beep
There's a program which simplifies playing and customizing frequencies of beeps through the PC Speaker:

XKBUtils
For historical purposes, providing only a simple bell or monotone beep, xkbbell:

On demand via console or script
On demand use of the PC speaker can be accomplished by using a simple echo statement using an escape sequence indicating the command line terminal to process a beep.

This echo statement is commonly placed within scripts and programs, to either indicate the task has finished, or has exited on error.

Johnath's beep
Johnath's beep utility, mentioned above and provided by the Gentoo package; provides frequency, length, delay, along with a few other much desired features. However seems to lack volume control. My guess the volume might be muddled in with the frequency of the beep.

See the bottom of the beep's manual page for further examples.

Typewriter effect
If you're unfortunate like the many of us nowadays and do not own a keyboard having a speaker for using "xset c", then you'll need to either script or program something, taking the keyboard events and playing a beep or sound.

The following options can either use app-misc/beep for simplicity and using fewer system resources, or use alsa-utils aplay for playing more dramatic effects. (Or insert your other favorite command line media player such as afplay for playing AIFF files.)

Bourne shell (bash)
A simple Bourne Shell o(bash script) utilizing.

Where xinput test argument is your AT Keyboard, extracted from, pipe the output to an infinite while variable (or until CTRL-C is pressed). Read each line via read and perform a REGEX search for lines containing "press" and if found use the beep command.

FIXME: Trying to alias the previous incantation within $HOME/.bashrc within double fails, likely due to *press* not being within quotes. Specifying the incantation within single quotes as an alias works.

FIXME: Trying to pipe the 'xinput' output to 'cut -b 5-' then to the infinite read while loop fails. This would be for using an if/then to omit modifier keys.

FIXME: If further omitting modifier keys (for which would be nice and more realistic), should condense the script to reduce the number of time consuming System or CPU processes.

VIM
Fortunately, VIM can be made to sound like a typewriter as you're typing by a simple vimrc script. From here, I use app-misc/beep for simplicity.

Python
Insert your favorite (if you must) very simplified Python script here.

No PC Speaker beeps or sounds
Make sure your motherboard has a speaker pin outputs along with a speaker attached, check your BIOS PC Speaker or BIOS Keyboard settings for older hardware, and make sure the pcspkr module is not blacklisted. Use the setterm and xset utilities above for increasing the beep length, and ensure GNU Screen is not using the visual bell. All this has been documented above.

Playing musical notes on the PC Speaker
See the package app-misc/beep manual page. (ie. man beep)

Toward the end of the beep manual page, is documentation corresponding approximate frequency correlations for each of the musical scale notes.

How do I mute the PC Speaker?
Some methods for disabling the PC Speaker:


 * The easy method, and once and for all solution for muting the PC speaker, add the pcspkr module to your "/etc/modprobe.d/blacklist.conf" file or omit compiling of the driver within the kernel.
 * For temporary or per user disabling, add "set bell-style none" or substitute "visual" for "none" within the /etc/inputrc file or the users $HOME/.inputrc file.
 * Other temporary or per user methods include setting the beep length to zero or disabling the bell using setterm and xset utilities.
 * If using GNU Screen, 'CTRL-a CTRL-g'; or adding "vbell off" or "vbell on" within your $HOME/.screenrc; but you'll still have the bell everywhere else unless any of the above are performed.