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"
14 if [ -f /tmp/away-actions.pid ]; then
15 oldpid="`cat /tmp/away-actions.pid`"
16 if kill -0 "$oldpid"; then
18 if [ -f /tmp/away-actions.pid ]; then
19 newpid="`cat /tmp/away-actions.pid`"
20 [ "$newpid" = "$oldpid" ] && kill "$newpid"
22 if [ -f /tmp/away-actions.pid && "`cat /tmp/away-actions.pid`" = "$oldpid" ]; then
24 rm /tmp/away-actions.pid
25 elif [ -f /tmp/away-actions.pid ]; then
30 rm /tmp/away-actions.pid
35 rm /tmp/away-actions.pid
39 echo "$$" >/tmp/away-actions.pid
42 #activity="`tpope activity`"
47 Sleeping|"Away from keyboard"|TV*|"") is_away=0 ;;
48 *[Cc]lass*) is_away=1 ;;
51 [ "$phone" = absent -a -z "$alive" ] && is_away=1
53 find /tmp -name .tpope_lights -maxdepth 1 -mmin 60 -exec rm {} \;
54 if [ "$is_away" = 1 -a ! -f /tmp/.tpope_lights ]; then
55 touch /tmp/.tpope_lights
58 for host in buster; do
59 ping -c 1 $host >/dev/null && $ssh $host tpope xssc -lock 2>/dev/null &
61 elif [ "$is_away" = 0 -a -f /tmp/.tpope_lights ]; then
63 rm -f /tmp/.tpope_lights
66 # for host in lucille; do
67 # ping -c 1 $host >/dev/null && $ssh $host tpope unlock
72 if [ "$information" = "On desktop" ]; then
73 echo > "$HOME/.caminfo.deskcam"
74 echo "- On desktop" > "$HOME/.caminfo.bedcam"
77 echo "- $information" > "$HOME/.caminfo.deskcam"
78 if [ "$information" = "In bed" ]; then
79 echo "" > "$HOME/.caminfo.bedcam"
81 echo "- $information" > "$HOME/.caminfo.bedcam"
83 #echo "$information" > "$HOME/.status"
84 echo "$information" > "$HOME/.plan"
87 for host in gob barry lucille buster oscar; do
88 ping -c 1 $host >/dev/null && scp -q "$HOME/.status" $host: 2>/dev/null
91 ping -c 1 lucille >/dev/null && scp -q "$HOME/.caminfo.deskcam" lucille:.caminfo 2>/dev/null
92 ping -c 1 buster >/dev/null && scp -q "$HOME/.caminfo.bedcam" buster:.caminfo 2>/dev/null
93 rm -f .caminfo.deskcam .caminfo.bedcam