Compacted grade output
[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 elif [ -f /tmp/.tpope_lights ]; then
22     br -n 5
23     rm -f /tmp/.tpope_lights
24     br -n 5
25 fi
26
27 if [ "$activity" ]; then
28     information="$activity"
29 elif [ "$away" ]; then
30     information="$away"
31 elif [ "$old_alive" = "lisa" ]; then
32     information="On laptop"
33 else
34     information=
35 fi
36
37 if [ -z "$information" ]; then
38     echo > "$HOME/.caminfo"
39     echo Here > "$HOME/.status"
40     rm -f "$HOME/.plan"
41 else
42     echo "- $information" > "$HOME/.caminfo"
43     echo "$information" > "$HOME/.status"
44     echo "$information" > "$HOME/.plan"
45 fi
46
47 ping -c 1 bart >/dev/null && scp -q "$HOME/.status" bart: 2>/dev/null
48 ping -c 1 abe >/dev/null && scp -q "$HOME/.status" abe: 2>/dev/null