2007-10-09

A very small shell script


#!/bin/bash
file=~/Desktop/zenbell.mp3
interval="30 min"
player=/usr/bin/mplayer

function usage()
{
    echo "Usage: $0 [OPTIONS]
Options:
 -f FILE:     play FILE (default: $file)
 -i INTERVAL: wait this much, in at(1) format (default: $interval)
 -p PLAYER:   use PLAYER (default: $player)"
    exit 1
}

while getopts "f:i:p:h" opt; do
    case $opt in
        f) file="$OPTARG";;
        i) interval="$OPTARG";;
        p) player="$OPTARG";;
        *) usage;;
    esac
done

sleep 100 # time to get away from the computer and sit
("$player" "$file"; "$player" "$file"; "$player" "$file") >&- &
at now + "$interval" <<EOF
"$player" "$file" >&-
EOF

No comments

No comments yet.

Comments RSS TrackBack

Leave a comment

You must be logged in to post a comment.