#!/bin/sh -e
# at_xmessage -- print messages on xwindows at a certain time.
# Copyright       : http://www.fsf.org/copyleft/gpl.html
# Author          : Dan Jacobson -- http://jidanni.org/comp/
# Created On      : Summer 2001
# Last Modified On: Wed Mar 25 03:03:56 2009
# Update Count    : 83
test -w / && { echo "$0: don't run as root, could have DISPLAY problems"
    exit 22;}
test $# -eq 0 -o "$1" = --help && exec cat<<EOF
$0: Usage:
$ echo Call Bob Plastowitz now|at_xmessage 10:48 am
Shell special characters in input are not interpreted, for safety.
EOF
cd /tmp #in case $PWD is gone when the at job runs
message="`cat`"
#env -: smaller at job file and no locale to tangle xmessage fonts
env - at "$@" <<EOF
echo "$message"|
XAUTHORITY=~/.Xauthority DISPLAY=:0.0 xmessage -file - && exit
echo "$0: $message"|wall
echo $0 $1: "$message"
EOF
#perhaps remind(1) already does all of this