At my school I want to automate the process of telling the students to go to class and play a song five minutes before class starts at the end of lunch.
I wrote a Bash script that will play the announcement, a random song. After five minutes the script will fade out the music and kill VLC. I need this script run on Windows as the is the OS used for announcements. It doesn't need to be Batch, but I must be able to run it on Windows.
Here is the script that I wrote:
#!/bin/bash
#Copyright (c) 2010, Jason Cook
#All rights reserved.
#Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#Neither the name of the Jason Cook nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#Set Arguments
song=$((RANDOM % 21))
volume_fade_counter=0
echo "Released under The BSD License"
echo
echo "11:55"
echo "Playing \"Get to Class\""
echo "Playing song number $song"
vlc /home/jason/Documents/Announcements-Lunch/get-to-class.mp3 /home/jason/Documents/Announcements-Lunch/$song.mp3 &
echo "Waiting for five minutes"
sleep 360
echo "Fading audio"
while [ $volume_fade_counter -le 100 ] ; do
aumix -v -1
volume_fade_counter=$(( $volume_fade_counter + 1 ))
done
echo "Killing VLC"
pkill vlc
exit