Ubuntu – How to set up an mp3 alarm clock

hibernatemodemultimediascheduled

I want to switch from Windows XP to Ubuntu and there is one thing that I'm heavily using in XP—an MP3 alarm clock. In the evening I turn the PC to hibernated mode. In the morning it wakes up (based on Windows' scheduler) and runs a special program that then runs media player with a defined playlist, starts music and then slowly volumes up the sound.

So, my question is, are all these features present in Ubuntu?

  • Hibernate PC with ease
  • Wake up from hibernate in a scheduled moment of time
  • Media player that can start playing music automatically (seems that's the problem on Windows, that's why i need a special program for that)

Best Answer

I don't have my laptop with me to try this right now, but I think this should work, or at least get you close:

echo $(date +%s -d"+ $(echo 8*60*60 | bc -l) seconds") > sudo tee /sys/class/rtc/rtc0/wakealarm ; sudo pm-suspend --auto-quirks ; ogg123 ~/Music/*.ogg

That's "8 hours from now" -- 8 hours * 60 minutes per hour * 60 seconds per minute. Adjust the timing as you see fit. (Yes, you can put 6.5*6*6 if you want 6 and a half hours--that's why I put in bc -l)

What it does is set an alarm for a specific second of time, which it's calculating based off of the numbers you enter, for when it should wake up. Then it calls the command that does suspending. When it resumes from suspend, it should move on to the third command in the line, which is the command to ogg123 to play all the .ogg's in your ~/Music (feel free to replace with mpg123 and *.mp3 or what-have-you).

You can also try with pm-hibernate instead of pm-suspend, but I'm not sure how well it'll work with the wakealarm. Even with suspend, how well various hardware supports wakealarm is uncertain until you try it.

Source of wakealarm info: http://people.canonical.com/~apw/suspend-resume/test-suspend