Hello again,

a simple bash script that you can run with

start-stop-daemon --start --background --exec /path/to/file

will do the job. Just adjust the value "timeout_sec" (time in seconds
after function timeout() will be called), "freq_sec" (time in seconds
of the pause between two checks) and
"substream" (/proc/asound/[substream]/status must exist, this card
channel will be monitored).

Greets
Torsten

#!/bin/bash

function timeout()
{
        echo "Timeout"
        exit
}

timeout_sec=5
freq_sec=2
substream=card0/pcm0p/sub0

last_usage=`date +%s`

while true; do
        now=`date +%s`
        if [ "`cat /proc/asound/${substream}/status`" != "closed" ]; then
                last_usage=${now}
        fi;
        if [ `expr ${now} - ${last_usage}` -gt ${timeout_sec} ]; then
                timeout
        fi;
        sleep ${freq_sec}
done



On Fri, 23 Mar 2012 09:07:02 +0100
Robert Bude <ru...@rupat.de> wrote:

> 
> 
> hi everybody, 
> 
> at home i have a mythbuntu media pc. it will shutdown
> if no tv recording is sheduled and no user programs like mediaplayers
> webbrowsers and so on open. this works with an preshutdown script
> which simply checks if one of the programs i define is still active.
> this works very good. the only problem is that sometimes i forgott to
> close vlc player or some other programs.  
> 
> so i have a new good idea to safe
> power consumption ;) my new plan is to monitor if the pc outputs
> sound. if this pc gives no music or tv sound it is on for nothing !
> the best way i think is to monitor the output of soundcard or device
> if there is activity at the last 15 minutes. if not shutdown. 
> 
> But how i can detect
> this ? 
> 
> Any hints or new directions are very welcome 
> 
> ps: i had a idea
> to detect when als is going in power safe mode, but this only works if
> outputs set to mute. so this is no alternative. 
> 
> Greetings from Robert
> from Cottbus, Germany ! 
> 
>  


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user

Reply via email to