Dandekarancha Salla (Dandekar's Advice)

Icon

Dandekar's Advice

Shell script to remove system-beeps in Crunchbang Linux

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 ‘beepoff.sh’) and make it executable by using the following command.

sudo chmod a+x beepoff.sh

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 etc…

# and I am not responsible for the outcome

# Blacklist pcspkr

if [ $(grep -c 'blacklist\ pcspkr' /etc/modprobe.d/pcspkr.conf) -eq 0 ]

then

echo ‘blacklist pcspkr’ | tee -a /etc/modprobe.d/pcspkr.conf

rmmod pcspkr

else

echo “blacklist pcspkr in pcspkr configuration”

fi

#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 ]

then

echo “gtk-error-bell = 0″ >> /home/$1/.gtkrc-2.0.mine

chmod 755 /home/$1/.gtkrc-2.0.mine

else

echo “gtk-error-bell already set to zero”

fi

# remove console beeps in X

if [ $(grep -c 'xset\ b\ off' /home/$1/.config/openbox/autostart.sh) -eq 0 ]

then

echo “\n# remove console beeps in X –Added by $1 \nxset b off &” >> /home/$1/.config/openbox/autostart.sh

else

echo “console beeps already off in autostart script”

fi

# 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 ]

then

echo “setterm -blength 0″ >> /etc/profile

echo “setterm -bfreq 0″ >> /etc/profile

else

echo “console beeps already off in /etc/profile”

fi

# remove login sound from gdm

if [ $(grep -c 'SoundOnLogin=False' /etc/gdm/gdm.conf) -eq 0 ]

then

sed -i ‘s/\[greeter\]/\[greeter\]\nSoundOnLogin\=False/’ /etc/gdm/gdm.conf

else

echo “login sound already off from gdm”

fi

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.

Filed under: crunchbang, linux, novice, tips and tools, , , ,

Removing entries from the ‘Open with Other Application’ menu in Ubuntu

So recently I decided to remove Wine once and for all… again. However, after doing so, I realized that the ‘Open with Other Application’ menu in Ubuntu 10.04 does not flush all the Wine-related entries in it (this menu can be accessed by right-clicking any file/folder in the file-system). I googled around to find a fix for this issue and did not find a good solution. The solution was finally found on some forums and was in a pretty fragmented state. So I am compiling it here.

Go to the ‘/home/<username>/.local/share/applications’ directory. Find all the Wine-related documents in there and delete them… just like that. Then open the ‘mimeapps.list’ file in the same folder using gedit (or your favorite text editor). Again find all Wine-related entries in the file and delete them. This can be tricky, so make a backup copy of the file before you change anything. That should get rid of those useless entries once and for all. This solution can probably be used to get rid of any entry. Try it and let me know.

Filed under: novice, tips and tools, ubuntu, , , , ,

Removing links from the Ubuntu applications menu

This post is going to be a short one. Interestingly, I had not learnt how to delete links from the Ubuntu applications menu. So when I needed to do this, it took me a while to find out how to do it. But it is really a very simple task. All you have to do is delete the icon or link from “/usr/share/applications”. Note that this will not delete the actual application.

I like accessing applications directly from the terminal. So I frequently have to do this. Also, for all the power-users out there, I would suggest that you give Gnome-do a try.

Filed under: novice, tips and tools, , ,

Using Gparted Live CD to partition a hard drive

Gparted livecd is one of the best ways one can partition an external hard drive. It is probably the safest way too. It is particularly useful in at least one scenario.(which I encountered interestingly) Consider that, you just received that flashy new external hard drive with Zillions of bytes of capacity on your office address (because you are single and don’t want to go to the UPS/FedEx “central customer center” to collect it). You wanna try it out right away. But it is not formatted so you decide to go about doing that. You plug it into your Win-do-do workstation and it never shows up. So you cannot format it. You go into My computer > Manage and you don’t have admin privileges… what are the odds of that!

Here is a brief walkthrough for using gparted.

1. The first step is downloading and writing the gparted live cd. Go here and download the gparted live cd iso. Then write it to a blank disc. (Such a cd can then become a permanent part of your computer utility cd stack)

2. The next thing to do is connect your external drive and boot from the live cd. Put in the Gparted livecd in. Shut down your computer. Connect your external hard drive to it. Restart your computer and go to the boot menu or bios to change the sequence in which you computer boots. Boot menu is usually triggered by f12 just when the computer starts.

3. Gparted Livecd(or rather debian) will ask you a couple of questions while booting such as keymaps, screen resolution and stuff. Keep all the default options (hopefully you wont have a lot of issues here) . Once you boot into gparted, it will detect your main hard drive and show the hard drive stats. Select the external hard drive in the dropdown menu. It should show up with all of its drive space unallocated. (At this point you make an instant choice between deleting your computer’s main drive and driving you boss mad and obviously resulting in you getting fired from the company, OR formating your external hard drive and everything stays the way it is. Assuming it is the latter choice, read on)

4. Now select the unallocated space for your external hard drive and make partitions. First set a disklabel, by selecting set disklabel from device the drop down. Just stay with the defaults. Next select a primary partition. this partition is necessary in case you want to boot from your hard drive later. Click on new and select primary partition in the menu. If you want just one partition for your entire drive, select the entire unallocated space. Else, modify the options accordingly. Specify a disk label if you want. If you want this drive to work well with windows select the drive format as NTFS. If you work with both linux and windows, most linux machines recognize NTFS so you should not have a problem, but you might want to consider FAT32. If you plan to use your hard drive with linux alone, go for ext2 or ext3. Don’t worry if you do not know any of these file systems. Just pick ntfs. You now should see a pending operation in the gparted status bar. Be warned though that there might be issues resizing NTFS partitions later, as gparted has its limitations.

5. In case you did not select all of your drive space as a primary partition, the rest of your unallocated hard drive space can be formatted as an extended partition. For more information on partitioning terminology, look here. Select the remaining unallocated space and click new. Select extended partition in the options menu. Once you select an extended partion, the space will still be unallocated but it will be under the extended partition. So select this unallocated space and make as many logical partitions in it as you need. Once you are done, review and edit any options you want before you proceed further because in the next step you apply the partitions permanently.

6. Select apply all pending operations from the partition drop-down. If you have a big hard drive and a lot of partitions, this can take a while.  And once that is done, shut down gparted  and your computer, and you should have a formatted external hard drive hungry for data.

Note: disklabels can be easily added, modified, or deleted, so in case you forgot to add a disk label… you can go back to gparted and add it.

*Update: After partitioning your hard drive with an ext3 partition in linux, the permissions are tied to the root user. So normal users cannot use that partition. This can be easily corrected by using chmod.

eg. ‘sudo chmod a=w /media/<yourdisklabel>’

Filed under: novice, tips and tools, , , , ,