#!/bin/sh

#######################
#
# Asynchronous Event Controller
# for Simple MP3 Jukebox
#
# KAWAMATA, Yoshihiro
# kaw@on.rim.or.jp
#
# $Id: asyncevent.sh,v 1.1 2005/07/22 15:15:38 kaw Exp $
#
#######################
 
dir="$1"
int=0.1

if [ -f $dir/mute ]; then
    mixerctl outputs.master=153
    sleep $int; mixerctl outputs.master=122
    sleep $int; mixerctl outputs.master=98
    sleep $int; mixerctl outputs.master=78
    sleep $int; mixerctl outputs.master=62
    sleep $int; mixerctl outputs.master=50
    sleep $int; mixerctl outputs.master=40
    sleep $int; mixerctl outputs.master=32
    sleep $int; mixerctl outputs.master=25
    sleep $int; mixerctl outputs.master=20
    sleep $int; mixerctl outputs.master=16
    sleep $int; mixerctl outputs.master=13
    sleep $int; mixerctl outputs.master=10
    sleep $int; mixerctl outputs.master=8
    sleep $int; mixerctl outputs.master=6
    sleep $int; mixerctl outputs.master=0
    rm $dir/mute
elif [ -f $dir/loud ]; then
    mixerctl outputs.master=6
    sleep $int; mixerctl outputs.master=8
    sleep $int; mixerctl outputs.master=10
    sleep $int; mixerctl outputs.master=13
    sleep $int; mixerctl outputs.master=16
    sleep $int; mixerctl outputs.master=20
    sleep $int; mixerctl outputs.master=25
    sleep $int; mixerctl outputs.master=32
    sleep $int; mixerctl outputs.master=40 
    sleep $int; mixerctl outputs.master=50
    sleep $int; mixerctl outputs.master=62
    sleep $int; mixerctl outputs.master=78
    sleep $int; mixerctl outputs.master=98
    sleep $int; mixerctl outputs.master=122
    sleep $int; mixerctl outputs.master=153
    sleep $int; mixerctl outputs.master=192
    rm $dir/loud
elif [ -f $dir/stop ]; then
    pkill -TERM mpg123
    rm $dir/stop
fi
