January 2005 Archives

01.09.2005 20:42

本學期第一週課程小感

累翻了。我還能說啥?嗯,希望今晚能做完作業!
英文還是個障礙就是了 -----

Posted by Wesly Chu | Permanent Link | Categories: Life

01.02.2005 21:53

My First Shell Script - MP3 Alarm Clock

Every thing has the begining. In order to use my PC as an alarm clock, I wrote this script for playing my MP3 files. This is my first shell script. It's very simple but works fine. It just checks the directiory which includes MP3 files then plays all MP3 randomly.
#!/bin/bash
MUSICDIR=/Gaia/My\ Music/

echo "#### Start MP3 Alarm ####"

/bin/aumix-minimal -w 75

if [ -d "$MUSICDIR" ]; then
	/usr/bin/mpg123 -g 90 -z "$MUSICDIR"*.mp3
else	
	/bin/mount /Gaia
	/usr/bin/mpg123 -g 90 -z "$MUSICDIR"*.mp3
	/bin/umount /Gaia
fi
/bin/aumix-minimal -w 75
Here is another version which uses playlist file.
#!/bin/bash
PLAYLIST=/Gaia/morningcall.m3u

echo "#### Start MP3 Alarm ####"

/bin/aumix-minimal -w 75

if [ -e "$PLAYLIST" ]; then
	/usr/bin/mpg123 -g 90 -z -@ "$PLAYLIST"
else	
	/bin/mount /Gaia
	/usr/bin/mpg123 -g 90 -z -@ "$PLAYLIST"
	/bin/umount /Gaia
fi
/bin/aumix-minimal -w 75
Before using this script, we must generate playlist first.
/usr/bin/locate *.mp3 > morningcall.m3u
Make sure to run this script with root crontab and set the BIOS alarm boot time.
It might be 10 years ago that I wrote DOS batch file....... -----

Posted by Wesly Chu | Permanent Link | Categories: Linux Script Note