1. HOWTO turn your USB enabled Router into the coolest Alarm clock ever


This HOWTO is a work in progress, I have it running, but need to recreate all the steps. This message will be removed once everything is in place.


1.1. Goals:

If you follow this HOWTO you should end up with a machine capable of:

1.2. Prerequisites:

These are the parts i used to achieve the above.

1.3. Caveats:

Things which still bother me

1.4. HOWTO:

/usr/bin/alarm - example: alarm 7:00 will set an alarm clock for 7:00

#!/bin/bash
if [ -z "$2" ]; then
        vol=50
else
        vol=$2
fi
echo "/usr/bin/alarm_play $vol" | at $1

/usr/bin/alarm_play - helper script for the alarm

#!/bin/sh
if [ -z $(mpc | grep playing) ]; then
        mpc --no-status clear
        mpc --no-status load alarm_pl
        mpc --no-status volume 0
        mpc --no-status random on
        mpc --no-status play
        mpc --no-status pause
        echo $1 > ~/.ppvolume
        /usr/bin/pp &
fi

/usr/bin/pp - fade sound in and out, this might be doable in a better way

#!/bin/bash

sleep="1s"
fade_sec="10"

curvol=`mpc | grep "volume" | cut -d " " -f2 | tr -d "%"`
if [ -z "`mpc | grep playing`" ]; then
    mpc play --no-status
    start=0
    end=`cat $HOME/.ppvolume`
    inc=$(($end/$fade_sec))
else
    echo $curvol > $HOME/.ppvolume
    start=$curvol
    inc=-$(($curvol/$fade_sec))
    end=0
fi
#echo $start $inc $end
for x in `seq $start $inc $end`; do
    mpc volume $x --no-status
#    mpc volume $x
    sleep $sleep
done

if [ $end -eq 0 ]; then
    mpc volume 0 --no-status
    mpc toggle --no-status
else
    mpc volume $end --no-status
fi

UsbAudioHowto2 (last edited 2008-05-12 23:42:25 by medha)

Almost all of these pages are editable, create an account and click the edit (Edit) button at the top of the page.