Skip to content

Instantly share code, notes, and snippets.

@MarcelloDuarte
Created November 2, 2011 06:24
Show Gist options
  • Save MarcelloDuarte/1333029 to your computer and use it in GitHub Desktop.
Save MarcelloDuarte/1333029 to your computer and use it in GitHub Desktop.
My improvised PHP alarm
<?php
date_default_timezone_set('Europe/London');
$alarm = '06:00';
$musicFileToPlay = '~/Music/4\ non\ blondes/1-01\ Train.mp3';
$open = 'open'; // change this to what is the command in you OS. This works for MacOSX
while (true) {
$date = date('H:i', time());
sleep(30);
if ($alarm === $date) {
echo 'Wake up!';
system ("$open $musicFileToPlay");
exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment