Index: gutenbach/debian/lib/cd-cddb
===================================================================
--- gutenbach/debian/lib/cd-cddb	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/cd-cddb	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+die () {
+    echo "$@";
+    exit 1;
+}
+
+CACHE=$(cd-cddb-get) || die "Unable to fetch CDDB information."
+
+. "$CACHE"
+
+echo "Artist: $DARTIST";
+echo "Album: $DALBUM";
+echo "Tracks: $TRACKS";
+
+for i in $(seq 1 $TRACKS); do
+    echo -n "Track $i: "
+    eval 'echo $TRACK'$i
+done
Index: gutenbach/debian/lib/cd-cddb-get
===================================================================
--- gutenbach/debian/lib/cd-cddb-get	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/cd-cddb-get	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+CDDBURL="http://freedb.freedb.org/~cddb/cddb.cgi"
+MYUSER="sipbmp3"
+MYHOST="zsr.mit.edu"
+
+DISCID=$(cd-discid /dev/cdrom 2>/dev/null) || exit 1
+
+set -- $DISCID
+
+ID="$1"
+TRACKS="$2"
+
+mkdir -p /var/cache/sipbmp3
+
+CACHEFILE="/var/cache/sipbmp3/$ID"
+
+if [ ! -e "$CACHEFILE" ]; then
+
+    CD=$(cddb-tool query "$CDDBURL" 3 "$MYUSER" "$MYHOST" $DISCID) \
+	|| exit 2;
+
+    file=$(tempfile)
+
+    cddb-tool read "$CDDBURL" 3 "$MYUSER" "$MYHOST" \
+	$(echo "$CD" | head -1 | awk '{print $2 " " $3}') > "$file"  \
+	|| exit 3;
+
+    echo "TRACKS=$TRACKS"   >  "$CACHEFILE"
+    cddb-tool parse "$file" >> "$CACHEFILE"
+
+    rm "$file"
+fi
+
+echo "$CACHEFILE"
+exit 0;
Index: gutenbach/debian/lib/cd-play
===================================================================
--- gutenbach/debian/lib/cd-play	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/cd-play	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+CDDB=
+
+CACHE=$(cd-cddb-get)
+
+if [ "$?" = 0 ]; then
+    CDDB=1
+fi
+
+. "$CACHE"
+
+play_one () {
+    T=$1
+    if [ -n "$CDDB" ]; then
+	DESC=" - "$(eval 'echo $TRACK'$T)
+    fi
+
+    echo "cdda://$(($T - 1))" | mit-lpr -Psipbmp3@localhost -J "Track $T$DESC";
+    echo "Queued Track $T$DESC";
+}
+
+TOPLAY="$2"
+
+if [ -z "$TOPLAY" -o "$TOPLAY" = "all" ]; then
+    for i in $(seq 1 "$TRACKS"); do
+	play_one $i
+    done
+else
+    shift;
+    for i in "$@"; do
+	play_one $i
+    done
+fi
Index: gutenbach/debian/lib/status-clear
===================================================================
--- gutenbach/debian/lib/status-clear	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/status-clear	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,2 @@
+#!/bin/sh
+> /var/run/sipbmp3/status
Index: gutenbach/debian/lib/status-get
===================================================================
--- gutenbach/debian/lib/status-get	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/status-get	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,2 @@
+#!/bin/sh
+cat /var/run/sipbmp3/status
Index: gutenbach/debian/lib/volume-down
===================================================================
--- gutenbach/debian/lib/volume-down	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/volume-down	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,2 @@
+#!/bin/sh
+volume-set . $(( $(volume-get .) - 1 ))
Index: gutenbach/debian/lib/volume-get
===================================================================
--- gutenbach/debian/lib/volume-get	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/volume-get	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,3 @@
+#!/bin/sh
+amixer get Headphone \
+ | perl -lne 'print $1 if (/Front Left: Playback ([0-9]+)/)'
Index: gutenbach/debian/lib/volume-help
===================================================================
--- gutenbach/debian/lib/volume-help	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/volume-help	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,14 @@
+#!/bin/bash
+cat <<EOF
+Usage: remctl zsr.mit.edu <command> <subcommand> [..args..]
+Commands:
+  volume up        - increment volume
+  volume down      - decrement volume
+  volume get       - get volume
+  volume set [vol] - set volume, in range 0..31
+  volume mute      - zero volume
+  volume help,
+   help <anything> - print this help
+
+'v', 'u', 'd' abbreviate 'volume', 'up', 'down' respectively.
+EOF
Index: gutenbach/debian/lib/volume-mute
===================================================================
--- gutenbach/debian/lib/volume-mute	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/volume-mute	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,2 @@
+#!/bin/sh
+amixer set Headphone toggle
Index: gutenbach/debian/lib/volume-set
===================================================================
--- gutenbach/debian/lib/volume-set	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/volume-set	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,3 @@
+#!/bin/sh
+amixer set Headphone "$2" \
+ | perl -lne 'print $1 if (/Front Left: Playback ([0-9]+)/)'
Index: gutenbach/debian/lib/volume-up
===================================================================
--- gutenbach/debian/lib/volume-up	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
+++ gutenbach/debian/lib/volume-up	(revision 83733c9953c0cff9045be18b5ad88ef948b78463)
@@ -0,0 +1,2 @@
+#!/bin/sh
+volume-set . $(( $(volume-get .) + 1 ))
