Console Jukebox

Some time ago we were having a few parties and found that my valuable CD collection was taking a real battering.  So I decided to convert an old Pentium 120 computer into a jukebox which stored and played mp3files on demand.  The console jukebox program was born!

The program, written in Perl, has the following features:
  • Simple, easy to use interface on the console screen (even my parents can work it!)
  • Scrollable song list
  • Select songs to queue for playing (works like a regular jukebox - pick the song - it goes in the queue - songs are played in the order they are selected)
  • Indication of current song and progress, number of songs in the queue and which songs are queued
  • Volume, fast forward and rewind control
  • Special emphasis to make it fool-proof for users - special keysdisabled
  • So far - proven to be crash-proof and "break-in" proof
  • The "T" version has a special volume control feature. After midnight, the maximum volume is reduced by about 15% every half hour - until it hits 25% volume. This "feature" makes sure that loud parties get quieter as the night (or morning) goes on. It's meant to give the neighbourssome relief!

Now the bad news:
  • The program currently needs to run with root privileges. Now this isnormally a very bad thing. But this program is designed to run on a dedicated, stand-alone PC (the sort you don't mind having the odd beer spilt over). I also modify certain system files for jukebox mode to ensure that no-one can get into the system and stuff things around (see below).
  • Being written in Perl, it's a big resource hungry for what it does. However, on my Pentium 120Mhz with 32MB RAM, it's never taken so much that the mp3 playing from local disk has been effected. It does have problems however if you're playing mp3s over a network (perhaps on a nfs mounted drive). Maybe this wouldn't be a problem with a faster CPU or more memory. Anyway, there a few things that can be tweaked in the program.
  • The program does not support multiple directories for mp3s - everything has got to be in one directory. This hasn't been a problem for me since I the computer is dedicated as a party jukebox. Before a party, I transfer about 2GB of songs from my server to this computer for playing at theparty.
  • Playlists are not supported. Of course not - the people at the party get to choose the songs and everyone else has to put up with them - just like a real jukebox. Fortunately you can abort poorly chosen songs.

Program Code

This is the Perl code for the Console Jukebox.

Here's the file :

# The following modules are required (get from

use Term::ReadKey;
use Term::ANSIScreen qw/:color :cursor :screen :keyboard/;
use Audio::Play::MPG123;

Now I don't pretend to be a professional "gun" programmer.  Experienced software types will find the style primitive, clumsy and very much like Basic programs of old.  I guess a reasonably experienced Perl programmer could acheive the same functions in half the lines.  Still, I hope the code is very readable and easy to modify for specific applications.

Of course, the source and program are made available free to anyone with absolutely no claims or warranties of performance or support.

Making your Jukebox hack proof

So by now I hope you realise that this program runs on my Jukebox PC that I put out for parties. It's a Pentium 120 with 32MB RAM, 6GB disk, and an old keyboard and monitor (no mouse is needed). It runs Redhat Linux 7.0.

To make the computer hack-proof and fool-proof, I modify the following files (I've written a simple script to do this automatically before aparty):


This file is modified to
  • remove additional consoles (so you can't Alt-Fn away from the jukebox)
  • start jukebox automatically on the console
  • make sure jukebox restarts automatically if stopped
  • ensure that Ctrl-Alt-Del does a shutdown (the only way to stop thesystem)
Here's the relevant sections:
# Run gettys in standard runlevels
#1:2345:respawn:/sbin/mingetty tty1
1:2345:respawn:/usr/bin/perl /home/jukebox/jukebox
#2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6
# Trap CTRL-ALT-DELETEca::ctrlaltdel:/sbin/shutdown -t3 -h now


Entries for the floppy (/dev/fd0) and cd-rom (/dev/cdrom) are removed for jukebox mode.


Change PROMPT to no to disallow prompted start-up:


Change the timeout to 0

I also stop a number of services from starting since the system won't be using samba, lp, etc.

To make it easy to change from normal mode to jukebox mode, I keep twoversions of the above files and have written two scripts:

echo ""
echo "Setting up jukebox mode (inittab, fstab, sysconfig/init, lilo.conf)"
cp /etc/inittab_jukebox /etc/inittab
cp /etc/fstab_jukebox /etc/fstab
cp /etc/sysconfig/init_jukebox /etc/sysconfig/init
cp /etc/lilo.conf_jukebox /etc/lilo.conf

mv /etc/rc.d/rc3.d/S90smb /etc/rc.d/rc3.d/_S90smb
mv /etc/rc.d/rc3.d/S90crond /etc/rc.d/rc3.d/_S90crond
mv /etc/rc.d/rc3.d/S90xfs /etc/rc.d/rc3.d/_S90xfs
mv /etc/rc.d/rc3.d/S95anacron /etc/rc.d/rc3.d/_S95anacron
mv /etc/rc.d/rc3.d/S99linuxconf /etc/rc.d/rc3.d/_S99linuxconf

echo ""
echo "Done"
echo "You now need to reboot to start dedicated jukebox mode"
echo ""


echo ""
echo "Setting normal devserver start-up mode (inittab, fstab, sysconfig/init, lilo)"
echo ""
cp /etc/inittab_normal /etc/inittab
cp /etc/fstab_normal /etc/fstab
cp /etc/sysconfig/init_normal /etc/sysconfig/init
cp /etc/lilo.conf_normal /etc/lilo.conf

mv /etc/rc.d/rc3.d/_S90smb /etc/rc.d/rc3.d/S90smb
mv /etc/rc.d/rc3.d/_S90crond /etc/rc.d/rc3.d/S90crond
mv /etc/rc.d/rc3.d/_S90xfs /etc/rc.d/rc3.d/S90xfs
mv /etc/rc.d/rc3.d/_S95anacron /etc/rc.d/rc3.d/S95anacron
mv /etc/rc.d/rc3.d/_S99linuxconf /etc/rc.d/rc3.d/S99linuxconf

echo "Done"
echo "You now need to reboot to start in normal mode"
echo ""

Once you're in jukebox mode, the only way to get back to normal_mode isto connect the box to a network and telnet into it as root, then run normal_mode.

Created by Greg Smith - Hosted on ( on Fedora - Server by Apache - CMS by - Template by