3 # -*- sh -*- vim:set ft=sh sw=4 sts=4:
5 # Checks several sources of information and updates my away status
6 # appropriately. Designed to be periodically called by away-tpope.
8 PATH="$HOME/bin:/usr/bin:/bin"
9 ssh="ssh -a -x -oBatchmode=yes -oSetupTimeOut=20"
12 if [ -f /tmp/away-actions.pid ]; then
13 oldpid="`cat /tmp/away-actions.pid`"
14 if kill -0 "$oldpid"; then
16 if [ -f /tmp/away-actions.pid ]; then
17 newpid="`cat /tmp/away-actions.pid`"
18 [ "$newpid" = "$oldpid" ] && kill "$newpid"
20 if [ -f /tmp/away-actions.pid && "`cat /tmp/away-actions.pid`" = "$oldpid" ]; then
22 rm /tmp/away-actions.pid
23 elif [ -f /tmp/away-actions.pid ]; then
28 rm /tmp/away-actions.pid
33 rm /tmp/away-actions.pid
37 echo "$$" >/tmp/away-actions.pid
40 #activity="`tpope activity`"
45 Sleeping|"Away from keyboard"|TV*|"") is_away=0 ;;
46 *[Cc]lass*) is_away=1 ;;
49 [ "$phone" = absent -a -z "$alive" ] && is_away=1
51 find /tmp -name .tpope_lights -maxdepth 1 -mmin 60 -exec rm {} \;
52 if [ "$is_away" = 1 -a ! -f /tmp/.tpope_lights ]; then
53 touch /tmp/.tpope_lights
56 for host in sarah homer; do
57 ping -c 1 $host >/dev/null && $ssh $host tpope xssc -lock 2>/dev/null &
59 elif [ "$is_away" = 0 -a -f /tmp/.tpope_lights ]; then
61 rm -f /tmp/.tpope_lights
65 ping -c 1 $host >/dev/null && $ssh $host tpope unlock
70 if [ "$information" = "On desktop" ]; then
71 echo > "$HOME/.caminfo.deskcam"
72 echo "- On desktop" > "$HOME/.caminfo.bedcam"
75 echo "- $information" > "$HOME/.caminfo.deskcam"
76 if [ "$information" = "In bed" ]; then
77 echo "" > "$HOME/.caminfo.bedcam"
79 echo "- $information" > "$HOME/.caminfo.bedcam"
81 #echo "$information" > "$HOME/.status"
82 echo "$information" > "$HOME/.plan"
85 for host in bart homer sarah clancy; do
86 ping -c 1 $host >/dev/null && scp -q "$HOME/.status" $host: 2>/dev/null
89 ping -c 1 homer >/dev/null && scp -q "$HOME/.caminfo.deskcam" homer:.caminfo 2>/dev/null
90 ping -c 1 sarah >/dev/null && scp -q "$HOME/.caminfo.bedcam" sarah:.caminfo 2>/dev/null
91 rm -f .caminfo.deskcam .caminfo.bedcam