Quozl's Open Source

Linux Halt Beep

Linux C Programming
Quozl had an old 486/100 that was shutdown daily, but it normally had no monitor attached. He needed a way to tell that it was ready to be powered down. This patch against 2.2.12 adds a small fragment of code to generate a descending tone sequence just after the "Power down" message.

(The function kd_mksound() from drivers/char/vt.c was used. This function starts the tone generation and normally schedules a timer to turn it off. Since the timers do not run at this point, the duration of the tones had to be set using msleep() macro calls.)

Since writing this, Quozl has been told that it could have been done in a process executed after the disks are unmounted. Oh well. Not half as much fun! Here's how, on Debian ...

  1. create a file /etc/init.d/beep containing the sound effect, for example:

    #!/bin/sh
    echo -n "\007" > /dev/console
    sleep 1
    echo -n "\007" > /dev/console
    sleep 1
    echo -n "\007" > /dev/console

  2. link it to the run level 0 so that it executes on shutdown

    # cd /etc/rc0.d
    # ln -s ../init.d/beep S85beep
Got too many machines shutting down? Consider the Debian package morse, which will let you emit a morse code signal identifying the machine.

(14 November 2000)


quozl@us.netrek.org