#!/bin/bash # Present -- show a dzen2 countdown and present via evince. # (c) 2010 Marco Fontani - MFONTANI at cpan dot org # Usage: present MINS SECS FILE set -bm COLOR='#444444' function countdown () { seq 1 ${1:-10} | tac | \ perl -ne'BEGIN{$|++;$msg=shift}$m=int($_/60);$s=int($_-$m*60);printf("$m:%02d -- $msg\n",$s);sleep 1;' \ "${2:-ready...}" } function countdown_cleanup () { pkill dzen2 exit } NMINS=$1 if [ -z "$NMINS" ]; then echo "$0 MINS SECS PDF FILE" exit 1 fi NSECS=${2} if [ -z "$NSECS" ]; then echo "$0 MINS SECS PDF FILE" exit 1 fi FILE=$3 if [ -z "$FILE" ]; then echo "Need a filename too" exit 1 fi if [ ! -f "$FILE" ]; then echo "Need an _existing_ filename too" exit 1 fi TOTSECS=$(echo "$NMINS*60+$NSECS" | bc) countdown 5 "Ready for $NMINS mins $NSECS secs ($TOTSECS)" | dzen2 -fg "$COLOR" trap 'countdown_cleanup' SIGCHLD evince -s $FILE & countdown "$TOTSECS" "GO" | dzen2 -fg "$COLOR"