Added away-actions
[tpope-extra.git] / bin / away-actions
1 #!/bin/sh
2 # $Id$
3 # -*- sh -*- vim: ft=sh sw=4 sts=4
4
5 # Performs routine actions based on my away status.  Designed to be
6 # periodically called by cron on homer.
7
8 away="`tpope away`"
9 activity="`tpope activity`"
10 ping -c 1 marge >/dev/null 2>&1 && eval `ssh marge cat .away-smart`
11
12 case "$away" in
13     Sleeping|"Away from keyboard"|"Adult Swim"|"") is_away=0 ;;
14     *[Cc]lass*) is_away=1 ;;
15 esac
16
17 [ "$old_phone" = absent ] && is_away=1
18
19 if [ "$is_away" = 1 ]; then
20     [ ! -f /tmp/.tpope_lights ] && touch /tmp/.tpope_lights && br -F -F
21 else
22     rm -f /tmp/.tpope_lights; br -n 5
23 fi
24
25 if [ "$activity" ]; then
26     information="$activity"
27 elif [ "$away" ]; then
28     information="$away"
29 elif [ "$old_alive" = "lisa" ]; then
30     information="On laptop"
31 else
32     information=
33 fi
34
35 if [ -z "$information" ]; then
36     echo > "$HOME/.caminfo"
37     echo Here > "$HOME/.status"
38     rm -f "$HOME/.plan"
39 else
40     echo " - $information" > "$HOME/.caminfo"
41     echo "$information" > "$HOME/.status"
42     echo "$information" > "$HOME/.plan"
43 fi
44
45 ping -c 1 bart >/dev/null && scp -q "$HOME/.status" bart: 2>/dev/null