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 ~
mkdir b43
cd b43
tar xjf b43-fwcutter-012.tar.bz2
cd b43-fwcutter-012

cd ..
tar xjf broadcom-wl-
cd broadcom-wl-
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 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
chmod 755
That's all there is to it.

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

Monday, 27 April 2009

Managing tunnels


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.


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


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

if [ -x $TUNN ]; then

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

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


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/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
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.
for((I=1;I<=100;I+=1)); do
/usr/bin/aumix -v$I -p100 -w100
sleep 5

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.
SONG="$HOME/Music/alarm clock song.ogg"
killall 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

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

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


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


FILE_TIME=`date +%H%M%S`

if [ ! -d $TARGET_DIR ]; then




fswebcam -c $CONFIG_FILE --save $FILE_NAME

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

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