Major changes to away system
[tpope-extra.git] / bin / away-actions
index c49a1dc936d8dfc225b1da9b9ac3002be9ae458c..2ae60efaadd6e5326b738e0fcbbd31d537857213 100755 (executable)
@@ -1,48 +1,66 @@
-#!/bin/sh
+#!/bin/bash
 # $Id$
-# -*- sh -*- vim: ft=sh sw=4 sts=4
+# -*- sh -*- vim:set ft=sh sw=4 sts=4:
 
-# Performs routine actions based on my away status.  Designed to be
-# periodically called by cron on homer.
+# Checks several sources of information and updates my away status
+# appropriately.  Designed to be periodically called by away-tpope.
+
+PATH="$HOME/bin:/bin:/usr/bin"
 
 away="`tpope away`"
 activity="`tpope activity`"
-ping -c 1 marge >/dev/null 2>&1 && eval `ssh marge cat .away-smart`
 
 case "$away" in
-    Sleeping|"Away from keyboard"|"Adult Swim"|"") is_away=0 ;;
+    Sleeping|"Away from keyboard"|TV*|"") is_away=0 ;;
     *[Cc]lass*) is_away=1 ;;
 esac
 
-[ "$old_phone" = absent ] && is_away=1
+[ "$phone" = absent ] && is_away=1
 
 if [ "$is_away" = 1 ]; then
-    [ ! -f /tmp/.tpope_lights ] && touch /tmp/.tpope_lights && br -F -F
+    [ ! -f /tmp/.tpope_lights ] && touch /tmp/.tpope_lights && \
+       $ssh homer br -F -F
 elif [ -f /tmp/.tpope_lights ]; then
-    br -n 5
+    $ssh homer br -n 5
     rm -f /tmp/.tpope_lights
-    br -n 5
+    $ssh homer br -n 5
 fi
 
 if [ "$activity" ]; then
     information="$activity"
 elif [ "$away" ]; then
     information="$away"
-elif [ "$old_alive" = "lisa" ]; then
-    information="On laptop"
 else
-    information=
+    case "$alive" in
+       lisa*|abe*) information="On laptop" ;;
+       sarah*) information="In bed" ;;
+       mona*|homer*) information="On desktop" ;;
+       *) information="Away from keyboard?" ;;
+    esac
 fi
 
 if [ -z "$information" ]; then
-    echo > "$HOME/.caminfo"
-    echo Here > "$HOME/.status"
+    echo > "$HOME/.caminfo.deskcam"
+    echo "- On desktop" > "$HOME/.caminfo.bedcam"
+    #echo "On desktop" > "$HOME/.status"
     rm -f "$HOME/.plan"
 else
-    echo "- $information" > "$HOME/.caminfo"
-    echo "$information" > "$HOME/.status"
+    echo "- $information" > "$HOME/.caminfo.deskcam"
+    if [ "$information" = "In bed" ]; then
+       echo "" > "$HOME/.caminfo.bedcam"
+    else
+       echo "- $information" > "$HOME/.caminfo.bedcam"
+    fi
+    #echo "$information" > "$HOME/.status"
     echo "$information" > "$HOME/.plan"
 fi
 
-ping -c 1 bart >/dev/null && scp -q "$HOME/.status" bart: 2>/dev/null
-ping -c 1 abe >/dev/null && scp -q "$HOME/.status" abe: 2>/dev/null
+for host in bart homer sarah clancy; do
+    ping -c 1 $host >/dev/null && scp -q "$HOME/.status" $host: 2>/dev/null
+done
+
+ping -c 1 homer >/dev/null && scp -q "$HOME/.caminfo.deskcam" homer:.caminfo 2>/dev/null
+ping -c 1 sarah >/dev/null && scp -q "$HOME/.caminfo.bedcam" sarah:.caminfo 2>/dev/null
+rm -f .caminfo.bedcam
+
+exit 0