Skip to content

Shell script to remove system-beeps in Crunchbang Linux

30 June, 2011

I am going to rant some on this post before I get to the solution. I have been a fan of Ubuntu Linux for a long time. In fact Ubuntu was the reason I started using Linux. But ever since Ubuntu 11.04 (Natty Narwhal) came out, I have faced some usability issues. I like the new Unity interface and I think that it has great potential. On the other hand Gnome is progressing on its own path of GUI evolution. However, mixing both of these GUI is not working out for me. In my opinion, this mix resulted in a mashup of two very diverging approaches of handling linux GUI. The bottom-line is that I have decided to wait on the fence until this GUI battle is over and then root for the winner later.  So I decided that I need to go to the next level of geek-dom and install a minimal Linux distro. My distro of choice is Crunchbang, just because. Anyways, it is a fun little distro and I still keep my Ubuntu Linux on a separate partition lest I need it someday.

Enough of that though… as the title states, this post is about a shell script to put an end to all the annoying system beeps you get in Crunchbang linux. The script is given below. (Or you can get it using the Pastie Link) Copy and paste this to a  file (say ‘’) and make it executable by using the following command.
sudo chmod a+x
Next run the script with root privileges with your username as an argument. So for example, if your username is ‘uname’, the command would be as follows.
sudo ./beepoff uname
This should get rid of almost all the system beeps. Please note that the script is just a compiled version of a solution that I found here  on the Crunchbang Forums. So if you prefer to do the typing yourself, you can make all the changes in the forum manually.
#! /bin/sh
# Shell script to disable (almost) all beeps on Crunchbang Linux
# @author: Akshay Dandekar
# @version: 0 (there will be no other)
# This script is free - do whatever you want with it
# and I am not responsible for the outcome

# Blacklist pcspkr
if [ $(grep -c 'blacklist\ pcspkr' /etc/modprobe.d/pcspkr.conf) -eq 0 ]
echo 'blacklist pcspkr' | tee -a /etc/modprobe.d/pcspkr.conf
rmmod pcspkr
echo "blacklist pcspkr in pcspkr configuration"

#set PC speaker and PC Beep to mute on amixer
amixer set 'PC speaker' 0% mute
amixer set 'PC Beep' 0% mute

# remove gtk application beeps
if [ $(grep -c 'gtk-error-bell\ \=\ 0' /home/$1/.gtkrc-2.0.mine) -eq 0 ]
echo "gtk-error-bell = 0" >> /home/$1/.gtkrc-2.0.mine
chmod 755 /home/$1/.gtkrc-2.0.mine
echo "gtk-error-bell already set to zero"

# remove console beeps in X
if [ $(grep -c 'xset\ b\ off' /home/$1/.config/openbox/ -eq 0 ]
echo "\n# remove console beeps in X --Added by $1 \nxset b off &" >> /home/$1/.config/openbox/
echo "console beeps already off in autostart script"

# remove bash beeps
sed -i 's/^#\ set\ bell\-style\ none/set\ bell\-style\ none/g' /etc/inputrc

# remove console beeps from the system console
if [ $(grep -c 'setterm\ -blength\ 0' /etc/profile) -eq 0 ]
echo "setterm -blength 0" >> /etc/profile
echo "setterm -bfreq 0" >> /etc/profile
echo "console beeps already off in /etc/profile"

# remove login sound from gdm
if [ $(grep -c 'SoundOnLogin=False' /etc/gdm/gdm.conf) -eq 0 ]
sed -i 's/\[greeter\]/\[greeter\]\nSoundOnLogin\=False/' /etc/gdm/gdm.conf
echo "login sound already off from gdm"

Also, an easier but riskier way of getting around the annoying system beeps is by disabling the pc speaker in BIOS. However, I do not know what the implications that would have on your computer. (For example, would the computer beep if you fall asleep on the keyboard? 🙂 or more seriously if the processor cooler fan stops working?) Also, I dual-boot my machine and would like to keep configuration settings separate for both OSes.

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: