PC speaker

About the PC Speaker
The PC Speaker is more commonly referred to the speaker located on the motherboard. Nowadays this is usually a simple piezoelectric speaker, but the piezoelectric speaker is enough to distinguish 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 Linx console or terminal, use the following. setterm -blength <0-2000> setterm -bfreq freqnumber

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.

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 or BASH
A simple Bourne Shell or BASH script utilizing app-misc/beep.

Where xinput test argument is your AT Keyboard, extracted from "xinput --list", 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.