Thursday, 17 September 2009

One step forward, one step back.

I have been playing around with the pre-release versions of Ubuntu 9.10 and the good news is that the off-the-shelf functionality of ATI/Radeon Xnnn cards is superb. The bad news is that support for BCM43xx devices is no longer automagic, so I had to do it myself. Again.

Here's a quickie guide for installing B43 drivers for Ubuntu 9.10.

My device is a BCM4311 802.11b/g WLAN (rev 01) and the current kernel version is 2.6.31-10.

Taking this article as inspiration, here is the quickie guide for my setup.cd ~
mkdir b43
cd b43
wget http://bu3sch.de/b43/fwcutter/b43-fwcutter-012.tar.bz2
tar xjf b43-fwcutter-012.tar.bz2
cd b43-fwcutter-012
make

cd ..
wget http://mirror2.openwrt.org/sources/broadcom-wl-4.150.10.5.tar.bz2
tar xjf broadcom-wl-4.150.10.5.tar.bz2
cd broadcom-wl-4.150.10.5/driver
sudo ../../b43-fwcutter-012/b43-fwcutter -w "/lib/firmware" wl_apsta_mimo.o
sudo modprobe b43

Don't forget the modprobe b43 at the end (not in the guide).

I have also managed to install the Broadcom STA drivers which is 'better'. Follow the README instructions and off you go.

Friday, 11 September 2009

Linux screen flicker Radeon X1200 Series

This is a public service announcement.

If you have an ATI Radeon Xnnnn graphics card, I suggest that update to the latest (at the time of writing) version 2.6.31 of the Linux kernel and you won't get dodgy screen flicker when viewing mostly black/grey content any more.

Again, at the time of writing, Ubuntu 9.10 (Karmic Koala) comes with this kernel version off the shelf and will be properly released in about a month from now.

Commended to the house.

For details of which of the Xnnnn graphics cards have improved support, look here.

FWIW, my device is:lspci | grep Radeon
01:05.0 VGA compatible controller: ATI Technologies Inc \
RS690M [Radeon X1200 Series]

That is all.

Sunday, 6 September 2009

Electric Sheep on Ubuntu 9.04

Electric Sheep is a lovely screen saver that I've been using for some time. I had a small amount of difficulty to get it to work with Ubuntu 9.04 (Jaunty), though it is simple enough to fix.

The authors of Electric Sheep have kindly provided a makesheep.sh script that doesn't quite work with Jaunty. In order to get it to work with this distro, do the following:# If you don't have subversion installed:
sudo apt-get install subversion
sudo apt-get install libavutil49
sudo apt-get install libavcodec-dev
sudo apt-get install libavformat-dev
wget http://electricsheep.org/makesheep.sh
chmod 755 makesheep.sh
./makesheep.sh
That's all there is to it.



Note: makesheep.sh works off the shelf with a vanilla install of Ubuntu 9.10 (Karmic).

Monday, 27 April 2009

Managing tunnels

Introduction

My laptop tunnels through to my home server for three services: smtp, imap and nntp. I thought it was about time that I managed these services in a completely automated and reliable fashion.

Objectives


I wanted my laptop to initiate the three tunnels every time a new network connection was established. The best place to do this is after if-up processes have been completed. Happily, the Network Manager executes scripts in /etc/network/if-up.d/ directory when such an event occurs.

I am assuming that you have a id_rsa.pub key in /root/.ssh already set up on the laptop and that this key has been appended to the file /root/.ssh/authorized_keys on the server. [TODO write this up]

Listing 1: /etc/network/if-up.d/tunnel

Is called after any if-up event. Calls the kill process first and then initiates new tunnels.#!/bin/sh

# /etc/network/if-up.d/tunnel

KILL=/usr/local/bin/kill-tunnels
TUNN=/usr/local/bin/start-tunnels

# quit if we're called for the loopback
if [ "$IFACE" = lo ]; then
exit 0
fi
# kill tunnel processes
if [ -x $KILL ]; then
$KILL
fi

if [ -x $TUNN ]; then
$TUNN
fi

Listing 2: /usr/local/bin/kill-tunnels

Kills the existing tunnel processes if they are running.#!/bin/sh

#/usr/local/bin/kill-tunnels

ps aux | grep "143\:localhost\:143" \
| sed 's/  */\t/g' | cut -f2 | xargs -r kill -15

ps aux | grep "25\:localhost\:25" \
| sed 's/  */\t/g' | cut -f2 | xargs -r kill -15

ps aux | grep "119\:localhost\:119" \
| sed 's/  */\t/g' | cut -f2 | xargs -r kill -15

Listing 3: /usr/local/bin/start-tunnels

Starts the new tunnels.#!/bin/sh

#/usr/local/bin/start-tunnels

HOST=my.server.fqdn

/usr/bin/ssh -f -N -q -L 143:localhost:143 $HOST

/usr/bin/ssh -f -N -q -L 25:localhost:25 $HOST

/usr/bin/ssh -f -N -q -L 119:localhost:119 $HOST

PROC=`basename $0`

logger -i -t $PROC Tunnels started
So it all works automagically, now and is particularly useful when in hotspots and changing connections.

As these procedures are called by root, I can use the ports numbered below 1024, which is handy.

So for nntp access, localhost:119 on my laptop is actually port 119 on my server.

Monday, 6 April 2009

Using Alias

I am forever using ssh to do something or other on another box from my laptop. Of course, whenever I need to run an X application to display on my machine I find out that I have forgotten to type the -X argumentssh -X 192.168.blahSo setting up alias to do this for me by default was the ideal solution.

First of all, edit ~./bashrc and uncomment the following lines:if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Then create a file ~/.bash_aliases to insert your alias comands.alias ssh='ssh -X'That's it. As an aside: for ssh -X to work, ensure you have the directive X11Forwarding yes enabled in /etc/ssh/sshd_config on the remote machine.

Alias in action

Tuesday, 31 March 2009

Simple CLI alarm clock using crontab and mplayer

Well, it had to be done, I suppose. I fancied an alarm clock which would wake me up with a music file of my choice and which would start off quietly and gradually get louder.

Getting started


In order to get the volume to increase gradually from the command line, you need to install aumix. If you don't have mplayer installed, then install it as well unless you wish to use something else.sudo apt-get install aumix mplayer

Volume Script


Next, create a script /usr/local/bin/wakeup-volume to increase the volume over time. Amend the sleep intervals and increments of I to suit.
#!/bin/bash
for((I=1;I<=100;I+=1)); do
/usr/bin/aumix -v$I -p100 -w100
sleep 5
done

Playing Script


Then create a script /usr/local/bin/alarm-clock and select your command line and music file you wish to wake up to. I am using mplayer and looping the music file five times in this example.

This script kills all wakeup-volume processes and starts a new wakeup-volume process before playing your tune of choice.
#!/bin/bash
PLAYER=/usr/bin/mplayer
SONG="$HOME/Music/alarm clock song.ogg"
killall wakeup-volume
/usr/local/bin/wakeup-volume&
$PLAYER -loop 5 "$SONG"
Last of all, set up crontab to wake you up. I have set mine to wake me up at 06:59 Monday to Friday.crontab -e59 6 * * 1-5 /usr/bin/X11/xterm -display :0 \
-bg black -fg green -e /usr/local/bin/alarm-clock
Note: crontab expects the above to be on one line. I have put a continuation escape character in because I don't have enough width on this here blog.

Don't forget to set execute rights on the two scripts...sudo chmod 755 /usr/local/bin/alarm-clock
sudo chmod 755 /usr/local/bin/wakeup-volume

Alarm clock in action



Further Reading:

mplayer documentation,
man aumix.

Sweet dreams.

Saturday, 28 March 2009

Acer Crystal Eye image capture

Intro
I have been idly attempting to get a utility to grab a frame from my laptop webcam (an Acer Crystal Eye).

Whilst the webcam works fine with the likes of Cheese, the act of perfoming an automated grab with the likes of CamE was unsuccessful. There is, I believe a problem with CamE, Ubuntu, the web cam and V4l2 working in harmony.

After trawling through the repositories, I finally found fswebcam which worked a treat.

Installingsudo apt-get install fswebcam
Configuring


In your home directory, create a file .fswc.confinput 0
top-banner
title "Prawn Cam"
timestamp "%d-%m-%Y %H:%M:%S (%Z)"
font /usr/share/fonts/truetype/freefont/FreeMono.ttf

Running

To demonstrate the flexibility of fswebcam, I generated a shell script to save a time-stamped file and copy the time-stamped file to another machine using scp.#!/bin/sh

TARGET_DIR="$HOME/.webcam"
OFFSITE_DIR="remote.server.name:/path/to/.webcam"
CONFIG_FILE="$HOME/.fswc.conf"

EXT="jpg"
FILE_TIME=`date +%H%M%S`
FILE_NAME=$FILE_TIME.$EXT

if [ ! -d $TARGET_DIR ]; then

mkdir $TARGET_DIR

fi

cd $TARGET_DIR

fswebcam -c $CONFIG_FILE --save $FILE_NAME
scp $FILE_NAME $OFFSITE_DIR/$FILE_NAME


That's it. Setup crontab to run the task as frequently as you wish.crontab -e

*/1 * * * * /usr/local/bin/webcap.sh
Will run the task every minute. (A little extreme, perhaps).