Friday, March 27, 2009

keeponline.sh (Yet another one)

I have posted two versions of my keeponline.sh script. (The one that checks if I have been disconnected from the net and reconnects)

Here's the latest one. It is now capable of checking if one instance is already running, and won't start another one unnecessarily:

#!/bin/bash
#echo "Going Online..."
#/usr/local/bin/online.sh > /dev/null
LOCKFILE="/var/lock/keeponline.lock"
trap "{ echo $0 removing lock; rm -f $LOCKFILE; exit 255; }" SIGINT SIGTERM
if [ -f $LOCKFILE ]; then
echo "$0: already running, exiting..."
exit 1
fi
touch $LOCKFILE
while true; do
ping -c 2 -W 120 www.google.com > /dev/null

if [ "$?" = "0" ]; then
echo "You are connected"
else
/usr/local/bin/online.sh > /dev/null
echo "Disconnect detected at `date`, reconnecting" >> /home/akshay/logs/keeponline.log
fi
sleep 10m
done


There is no real use for this script, since SuperSify provides this feature. But I found that my version has less number of false positives when the bandwidth is completely choked. Besides, I just wanted to learn how to use traps :)

Thursday, March 26, 2009

How I increased sound volume in ubuntu

Ever since I upgraded my machine, I got very low sound volume in Ubuntu. In windows, the volume was nice and loud enough. After digging around a lot, I tried something on my own and it worked! (Yes, I had tried playing around with all the volume controls in alsamixer)

I have an NVidia nForce 630i board and I'm using the onboard sound card:

00:0a.0 PCI bridge: nVidia Corporation MCP73 PCI Express bridge (rev a1)


For some strange reason, I see four mixer devices:


I use pulseaudio as my default sound server. Here's what I did:

Under System > Preferences > Sound, I changed my Default Mixer Tracks to Playback: ALSA PCM on front :0 (ALC662 Analog) via DMA (PulseAudio Mixer)


Right clicked on the volume control applet in the panel > Preferences. Here, I could choose the default device and track to control. I chose the same: Playback: ALSA PCM on front :0 (ALC662 Analog) via DMA (PulseAudio Mixer). (There's only a master track).


Finally, I made all the other relevant volumes 100% in all the other devices (except capture devices). Don't forget to click on the "Preferences" button to see all the tracks


I'm essentially using only the Playback: ALSA PCM on front :0 (ALC662 Analog) via DMA (PulseAudio Mixer) for controlling my volume. I don't know why or how this works, but it works for me...

The only problem is that it won't remember my volume levels after I reboot.