January 2005 Archives
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.
It might be 10 years ago that I wrote DOS batch file....... -----
#!/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 75Here 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 75Before using this script, we must generate playlist first.
/usr/bin/locate *.mp3 > morningcall.m3uMake 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....... -----