PC speaker - ArchWiki

Jump to content

# PC speaker

From ArchWiki

Related articles

- Advanced Linux Sound Architecture
- Kernel modules

PC speaker—beeper—is a built-in loudspeaker in most personal computers since the first IBM PC. This speaker is not capable of high quality playback and merely serves as a simple means of auditory feedback in the form of beeps. Some software—e.g. web browsers, editors and terminals—may produce beeps which may or may not be desired by the user. This article serves as a guide for configuring and/or disabling the speaker entirely.

For situations where no sound card or speakers are available and a simple audio notification is desired, see #beep.

## Mechanism

The PC speaker is typically a physical unit connected on the front connections header of the motherboard. Some motherboard manufacturers do not ship their motherboards with a PC speaker at all, whereas others may have the PC speaker soldered directly onto the surface. Laptops typically have no physical PC speaker but have the beeper routed to the laptop internal speakers. In some cases, the beeper is heard on the regular output—i.e. speakers or headphones—of the soundcard, which tends to be unexpectedly loud.

Upon boot the UEFI/BIOS will traditionally generate a beep during power-on self-test (POST). Recent motherboard models omit the POST beep in favor of rapidly booting into the operating system. The UEFI user interface typically allows for toggling the POST beeps but it cannot configure the PC speaker to be turned off completely.

Once the system has booted into Linux and the `pcspkr` kernel module is loaded, the PC speaker can be used by the environment, be invoked manually by the user, and be configured to some extent.

Because the PC speaker is controlled directly by the CPU, along with the fact that they are built for beeping only, PC speaker cannot be used for playing back audio files. If this is really desired, unloading the `pcspkr` module and installing the snd-pcsp-dkmsAUR package provides a rudimentary audio output.

## Disabling the PC speaker

### Physically

By removing the PC speaker the system will not be able to produce beeps. This can be achieved by physically removing the unit from the motherboard (if possible). Some manufacturers may provide a jumper header to switch it off.

Warning Removing the PC speaker is generally not recommended as it is a useful tool in diagnosing boot problems, after which it may produce a unique beeping pattern related to the source of fault (refer to your motherboard manual). A better solution is to turn off the POST beeps in the UEFI user interface and blacklisting the beeper as written below. If you do however wish to remove it physically it is highly recommended to keep it at bay for this scenario.

### Globally

The PC speaker can be disabled by unloading the `pcspkr` and `snd_pcsp` kernel modules:

Note This will not disable your entire sound system, only the PC speaker.
Tip The `snd_pcsp` module is a Linux kernel driver for the PC speaker which allows it to act like a primitive sound card to produce full PCM sound. It appears as an ALSA device, and also replaces the `pcspkr` driver for beeps. This module does not exist in the official Arch Linux kernels (unless you explicitly choose to install it, see snd-pcsp-dkmsAUR), but certain custom kernels include it by default.

    # rmmod pcspkr
    # rmmod snd_pcsp

Blacklisting the `pcspkr` and `snd_pcsp` modules will prevent udev from loading them at boot. Create the file:

    /etc/modprobe.d/nobeep.conf

    blacklist pcspkr
    blacklist snd_pcsp

Blacklisting it on the kernel command line is yet another way. Simply add `module_blacklist=pcspkr,snd_pcsp` to your boot loader kernel line.

### Console

#### Virtual console

In virtual console (TTY) you can set the bell duration to zero milliseconds with setterm(1):

    $ setterm --blength=0

#### Readline-aware shell

For a shell which utilizes the Readline library (e.g. Bash), uncomment this line in `/etc/inputrc` (or add it to `~/.inputrc`):

    set bell-style none

#### Less pager

To disable PC speaker in less(1) pager, you can launch it with `less --quiet` to mute PC speaker for end of file events, or `less --QUIET` to mute it altogether. For man pages, launch `man --pager="less --QUIET"` or set the `$MANPAGER` or `$PAGER` environment variables.

Alternatively, you can add these lines to your shell configuration file:

    alias less='less --QUIET'
    alias man='man --pager="less --QUIET"'

#### Arch Linux ISO

If you want to disable the init tune on the Arch Linux ISO, you will need to repack the ISO. To do so, first install the libisoburn and mtools packages.

Extract the El Torito boot images and systemd-boot configuration (`loader.conf`) from the ISO:

    $ osirrox -indev archlinux-YYYY.MM.DD-x86_64.iso -extract_boot_images ./ -extract /loader/loader.conf loader.conf

Make `loader.conf` writable and remove the `beep` option from it:

    $ chmod +w loader.conf
    $ sed '/^beep on/d' -i loader.conf

Add the modified `loader.conf` to the El Torito UEFI boot image:

    $ mcopy -D oO -i eltorito_img2_uefi.img loader.conf ::/loader/

Finally, repack the ISO using the modified boot image and `loader.conf`:

    $ xorriso -indev archlinux-YYYY.MM.DD-x86_64.iso \
    	-outdev archlinux-YYYY.MM.DD-x86_64-silent.iso \
    	-map loader.conf /loader/loader.conf \
    	-boot_image any replay \
    	-append_partition 2 0xef eltorito_img2_uefi.img

Note Only the init tune will be disabled. Beeps may still be played after booting. To disable the PC speaker after booting, see #Globally.

### ALSA

For most sound cards the PC speaker is listed as an ALSA channel, named either PC Speaker, PC Beep, or Beep. To mute the speaker, either use alsamixer(1) or amixer(1), for example:

    $ amixer set 'PC Speaker' 0% mute

To unmute the channel, see Advanced Linux Sound Architecture#Unmuting the channels.

### Cinnamon

Cinnamon seems to play a "water drop" sound. To disable it, set in gsettings(1):

    $ gsettings set org.cinnamon.desktop.wm.preferences audible-bell false

### GNOME

Using GSettings:

    $ gsettings set org.gnome.desktop.wm.preferences audible-bell false

### GTK

Append this line to `~/.gtkrc-2.0`:

    gtk-error-bell = 0

Add the same line to the [Settings] section of `$XDG_CONFIG_HOME/gtk-3.0/settings.ini`:

    [Settings]
    gtk-error-bell = 0

This is documented in the Gnome Developer Handbook.

### Plasma

Bell notification settings can be modified in System Settings > Accessibility Options > Bell.

### PulseAudio

Play a sound instead of a PC speaker beep using PulseAudio#X11 Bell Events.

Tip PulseAudio proxy controls might not list the PC speaker. If the PC speaker channel is not listed for the default ALSA device, try selecting the device corresponding to the sound card.

### Xorg

    $ xset -b

You can add this command to a startup file such as `/etc/xprofile` to make it permanent. See xprofile and xset(1) for more information.

## beep

beep(1) is a PC speaker beeping program. beep is useful for situations where no sound card and/or speakers are available, and simple audio notification is desired.

Tip A user can create a short audible tone when logged in to a virtual console, see Wikipedia:Bell character#Usage for the details.

### Installation

Install the beep package.

You may also need to unmute the PC speaker in ALSA.

### Configuration

beep uses `/dev/input/by-path/platform-pcspkr-event-spkr` to control the PC speaker which belongs to the `input` group, but adding user to `input` is not recommended by an upstream. To access the device file one has to set the proper permissions.

Note beep aborts if it is being run via sudo, with the root user or as SUID root. For more information, see PERMISSIONS.

The following rule will allow any user, who is logged into the currently active virtual console session, to use the PC speaker:

    /etc/udev/rules.d/70-pcspkr-beep.rules

    ACTION!="remove", SUBSYSTEM=="input", ATTRS{name}=="PC Speaker", ENV{DEVNAME}!="", TAG+="uaccess"

Previous solution does not allow to use beep for users logged in remotely—e.g. via OpenSSH,—or processes running as any user other than the one logged into the currently active virtual console session. Alternatively, a new user group may be created with the corresponding rule to set the right permissions on the device file. With this solution any user in the `beep` group will be able to control the PC speaker:

    ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PC Speaker", ENV{DEVNAME}!="", GROUP="beep", MODE="0620"

To force reloading rules and device file to apply new user permission without a reboot, execute:

    # udevadm control --reload && rmmod pcspkr && modprobe pcspkr

### Usage

The following example plays slightly higher and shorter sound than beep default—see beep(1) § Tone options,—and repeats it two times:

    $ beep -f 500 -l 50 -r 2

Repositories collecting shell scripts playing various music using beep:

- https://github.com/NaWer/beep
- https://github.com/ShaneMcC/beeps

See also beep(1) § Sound Volume.

## Troubleshooting

### The HD Audio power-saving mode mutes the PC speaker

The PC speaker might remain silent when the HD Audio sound card is in power-saving mode. Apparently—depending on hardware—the beeps are actually fed as an analog input into the card, and will be ignored if the card is asleep. You can debug this by playing music (to keep the card awake) in one virtual console and then beeping in another.

For more information, see Advanced Linux Sound Architecture/Troubleshooting#Power saving.

Category:

- Sound

PC speaker
Add topic