X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=X%2Ftp_alert.sh;fp=X%2Ftp_alert.sh;h=43109e0473e66817babbe73b22e6a0f1a7472600;hb=e2db5d1581339bf6f891b81879130d5e1f3298fc;hp=0000000000000000000000000000000000000000;hpb=874fac4e15be441861de05fca98ac714bb679ae3;p=shutils.git diff --git a/X/tp_alert.sh b/X/tp_alert.sh new file mode 100755 index 0000000..43109e0 --- /dev/null +++ b/X/tp_alert.sh @@ -0,0 +1,126 @@ +#!/bin/bash +# +# Stefan Huber +# +# ChangeLog: +# * 2009-07-24: Initial version +# * 2010-10-09: Use more shell commands + + +# Wait this amount of time until we activate lock +INITWAIT="0" +# Wait this amount of time after an alert call +ALERTPOSTWAIT="2" +# Busy wait for polling position sensor +BUSYWAIT="0.2" +# Tolerance for sensor differences +TOLERANCE="5" +# Position file +POSFILE="/sys/devices/platform/hdaps/position" + + +#Set the paths +export PATH="/bin:/usr/bin" +export DISPLAY=":0" + +state=0 +alert() { + amixer -q sset Master 100%,100% unmute + echo "Alert $state at time `date`" + + case $state in + 0) + echo "Leave me alone!" | festival --tts + state=1 + ;; + 1) + echo "E-mail sent!" | festival --tts + sendemail + state=2 + ;; + *) + sendemail + while isActive; do + echo "HELP!" | festival --tts + done + return + ;; + esac + sleep $ALERTPOSTWAIT +} + +sendemail() { + /usr/sbin/sendmail $USER <