#!/bin/sh trap "export STOP=1" SIGINT SIGKILL DAYS=21 DIR=~/var while ! echo $STOP | grep -q 1 ; do clear echo -e "\033[1;30mPast $DAYS days of media files below $DIR randomized. q next, space pauses, ^C quits\033[0m" mplayer -quiet "`find $DIR -ctime -$DAYS \( -iname '*.mp3' -o -iname '*.ogg' -o -iname '*.flac' \) | while read line ; do echo "$RANDOM---$line" ; done | sort | head -n1 | sed s/^.*---//`" 2> /dev/null | grep -E 'Playing |Title:|Artist:|Album:|Year:' done