Difference between revisions of "PC speaker"

From ArchWiki
Jump to: navigation, search
(Merging Beep and Disable PC speaker)
(redoing merge, wiped page)
Line 1: Line 1:
== Introduction ==
The computer often seems to make beep noises or other sounds at various times, whether we want them or not. They come from various sources, and as such, you may be able to configure if or when they occur.
In situations where no sound card or speakers are available and simple audio notification is desired, use {{pkg|beep}}. The {{pkg|beep}} package provides an advanced PC speaker beeping program.
Sounds from the computer can be heard from the built-in case speaker, the speakers, or headphones which are plugged into the sound card (in which case the noise may be unexpectedly loud). Turning off a particular instance of a sound, while leaving the others operational, is possible if and only if one can identify which portion of the environment generates the particular sound. This allows for a customized selection of attention-getting sounds possible. Please feel free to add any configurations and settings to this wiki page that may be useful for other users.
{{Note|The sounds are caused by the BIOS (Basic Input/Output System), the OS (Operating System), the DE (Desktop Environment), or various software programs. The BIOS is a particularly troublesome problem because it is kept inside an EPROM chip on the motherboard, and the only direct control the user has is by turning the power on or off.  Unless the BIOS setup has a setting you can adjust or you wish to attempt to reprogram that chip with the proper light source, it is not likely you will be able to change it at all. BIOS-generated beep sounds are not addressed here, except to say that unplugging your computer case speaker will stop all such sounds from being heard.  (Do so at your own risk.)}}
The PC speaker can be disabled by [[Kernel modules#Manual_module_handling|unloading]] the {{ic|pcspkr}} module, which is provided by the {{pkg|linux}} kernel:
# rmmod pcspkr
[[Blacklisting]] the {{ic|pcspkr}} module will prevent [[udev]] from loading it at boot:
# echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf
[[Kernel_modules#Using_kernel_command_line_2|Blacklisting it on the kernel command line]] is yet another way. Simply add {{ic|1=modprobe.blacklist=pcspkr}} to your bootloader's kernel line.
== Locally ==
=== Console ===
You can add this command in {{ic|/etc/profile}} or a dedicated file like {{ic|/etc/profile.d/disable-beep.sh}} (must be executable):
setterm -blength 0
Another way is to add or uncomment this line in {{ic|/etc/inputrc}} or {{ic|~/.inputrc}}:
set bell-style none
=== ALSA ===
{{Tip|For most Intel's cards, if you do not see a channel named PC Speaker or Beep in alsamixer's default device, then try selecting the correct card by pressing F6 (e.g. "HDA Intel PCH"). It is listed as "Beep" there. This is because PulseAudio proxy controls may not list all PC Speakers.}}
Try muting the PC Speaker:
$ amixer set 'PC Speaker' 0% mute
For certain sound cards, it is the PC Beep:
$ amixer set 'PC Beep' 0% mute
Or merely Beep:
$ amixer set 'Beep' 0% mute
You can also use alsamixer for a console GUI
$ alsamixer
The channel can also be unmuted by using the {{ic|↑}} key to increase the volume of the channel.
Press {{ic|Esc}} to close alsamixer.
To persist the current ALSA Mixer state, save the settings:
# alsactl -f /var/lib/alsa/asound.state store
{{Note|Not every sound card creates a PC Speaker or PC Beep slider control in alsamixer.}}
=== Xorg ===
$ xset -b
You can add this command to a startup file, such as [[xprofile]] to make it permanent.
=== GNOME ===
Using GSettings:
$ gsettings set org.gnome.desktop.wm.preferences audible-bell false
=== Cinnamon ===
Cinnamon seems to play a "water drop" sound. To disable it, set in dconf:
$ dconf write /org/cinnamon/desktop/wm/preferences/audible-bell false
=== GTK+ ===
Append this line to {{ic|~/.gtkrc-2.0}}:
gtk-error-bell = 0
Add the same line to the [Settings] section of {{ic|$XDG_CONFIG_HOME/gtk-3.0/settings.ini}}:
gtk-error-bell = 0
This is documented in the [https://developer.gnome.org/gtk3/stable/GtkSettings.html Gnome Developer Handbook].
== Beep ==
[[Install]] the {{Pkg|beep}} package.
=== Access for non-root users ===
By default {{ic|beep}} will fail if not run by the root. Other users may call it using [[sudo]]. To let group {{ic|users}} call {{ic|sudo beep}} without a password (for example to use it in scripts), {{ic|/etc/sudoers}} [[Sudo#Using_visudo|should be edited]]:
%users ALL=(ALL) NOPASSWD: /usr/bin/beep
or, to let only a single user do that:
username ALL=(ALL) NOPASSWD: /usr/bin/beep
Another way is setting the sticky bit on {{ic|/usr/bin/beep}}:
# chmod 4755 /usr/bin/beep
Note however that this way '''anyone''' can execute {{ic|/usr/bin/beep}} with root permissions. The change also creates a difference between local copy and the package, which will be reported by {{ic|pacman -Qkk}}.
=== Tips and Tricks ===
While many people are happy with the traditional beep sound, some may like to change its properties a bit. The following example plays slighly higher and shorter sound and repeats it two times.
# beep -f 5000 -l 50 -r 2
== See also ==
* Have a look at these {{ic|man}} pages for further information: {{ic|xset(1)}}, {{ic|setterm(1)}}, {{ic|readline(3)}}.
* [[Kernel modules]]
*[[Advanced Linux Sound Architecture]]

Revision as of 18:38, 9 November 2016