From: Tim Pope Date: Thu, 16 Sep 2004 23:58:34 +0000 (+0000) Subject: A lot of tweaks, particularly concerning the MHC schedule X-Git-Url: http://git.tpope.net/?p=tpope-extra.git;a=commitdiff_plain;h=86181f02570c74b5e1ab2952baf31d8171754044 A lot of tweaks, particularly concerning the MHC schedule --- diff --git a/bin/away-detect b/bin/away-detect index 57a89e5..e7b5052 100755 --- a/bin/away-detect +++ b/bin/away-detect @@ -32,8 +32,9 @@ trap 'rm -f "/tmp/LCK..`basename $0`"' EXIT echo $$ > "/tmp/LCK..`basename $0`" set_smart() { - [ -z "$old_away" -o "$old_away" = "$old_smart" ] && \ - tpope away "$*" + if [ -z "$old_away" -o "$old_away" = "$old_smart" ] || [ "$phone" = present -a "$old_phone" = absent ]; then + tpope away "$*" + fi smart="$*" } @@ -43,8 +44,6 @@ set_custom() { } set_out() { - # Away message is empty or older then our "smart" flag - #[ -n "$old_away" -a "$HOME/.away" -nt "$HOME/.away-smart" ] || \ [ -z "$old_away" -o "$old_away" = "$old_smart" ] && \ tpope away "$*" set_smart "$*" @@ -52,7 +51,6 @@ set_out() { set_in() { if [ "`date +%k`" -ge 2 -a "`date +%k`" -le 9 ]; then - #[ -n "$old_away" -a "$HOME/.away" -nt "$HOME/.away-smart" ] || \ set_smart "$sleeping" else set_smart "$*" @@ -69,22 +67,26 @@ set_active() { now="$(expr 60 \* $(date +%H) + $(date +%M))" -today --category='school' | sed -e s/^..........// -e 's/ \[.*\]$//'|grep '[0-9][0-9]:[0-9][0-9]-[0-9][0-9]:[0-9][0-9]'| \ +today --category=school | sed -e s/^..........// -e 's/ \[.*\]$//'|grep '[0-9][0-9]:[0-9][0-9]-[0-9][0-9]:[0-9][0-9]'| \ while read times event; do begin="$(expr 60 \* $(echo $times|sed -e 's/-.*//' -e 's/:/ + /g'))" end="$(expr 60 \* $(echo $times|sed -e 's/.*-//' -e 's/:/ + /g'))" max_end="$end" + end="`expr 3 \* $begin / 4 + $end / 4`" begin="`expr $begin - 15`" - end="`expr $begin / 2 + $end / 2`" + echo $begin $now $end $max_end if [ "$begin" -le "$now" -a "$now" -lt "$end" ]; then - echo "scheduled=\"Class ($event)\"" > "$HOME/.away-smart" + echo "scheduled=\"Class ($event)\"" >> "$HOME/.away-smart" break elif [ "$old_away" = "Class ($event)" -a "$now" -gt "$max_end" ]; then echo "old_smart=\"$old_away\"" > "$HOME/.away-smart" + echo HI MOM fi done -today --category='!school' | sed -e s/^..........//|grep '[0-9][0-9]:[0-9][0-9]-[0-9][0-9]:[0-9][0-9]'| \ +cat ~/.away-smart + +today --category='!school'\ '!private' | sed -e s/^..........// -e 's/ \[[^[]*\]$//'|grep '[0-9][0-9]:[0-9][0-9]-[0-9][0-9]:[0-9][0-9]'| \ while read times event; do begin="$(expr 60 \* $(echo $times|sed -e 's/-.*//' -e 's/:/ + /g'))" end="$(expr 60 \* $(echo $times|sed -e 's/.*-//' -e 's/:/ + /g'))"