5

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)
Kazark
  • 698
Anton N
  • 153

3 Answers3

6

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

maco
  • 15,892
  • I will acepth this answer, thank you! Though it didn't work for me right now - i'll need further research on this topic. Right now, i'm setting the alarm in the bios directly and crontab mpg123 thing on five minutes later after that :) – Anton N Oct 26 '10 at 11:56
1

Here is a post on the forums that might get you started in the right direction. But it looks like the answer is yes.

It says:

You can use sleep together with rhythmbox (which is installed by default), assuming you've got some .wavs or .oggs (or mp3s, and installed support for them).

Open rhythmbox from the sound & video menu, and import whatever sound file you want to wake up to. Then open a terminal, and run the command 'sleep nh && rhythmbox --play-pause' (replace n with the number of hours you want it to wait before playing, it doesn't have to be an integer.)

TheXed
  • 26,536
  • as far as i get it - sleep won't hibernate the pc, which means that i'll have to keep it on all night, which is inconvinient – Anton N Oct 22 '10 at 16:43
  • I don't think you can make any program turn on your computer at a preset time and then start playing music... in in effort to wake you up... – TheXed Oct 22 '10 at 16:50
  • Well, windows xp does exactly this kind of thing. I'm pretty sure that it messes up with bios, but it looks very user-friendly in the os. I hope ubuntu has this kind of stuff too. – Anton N Oct 22 '10 at 17:17
  • My comment was not to say there is no way, it was just to say that I am not aware of a way, also I have never seen a BIOS that does that... but once again that doesn't mean there are not... In fact that sounds like a very logical thing to allow... especially for servers... you could have them shut down over night, turn on in the morning before the work day starts and no one knows any different... anyways good luck finding a solution that works for you. – TheXed Oct 22 '10 at 17:41
  • and @Anton N You may want to have a look at this question and answers: http://askubuntu.com/questions/8845/how-do-i-schedule-waking-up-from-hibernation – marenostrum Oct 23 '10 at 03:05
1

For the hibernate part try loooking on this article about ACPI Wakeup

sergio91pt
  • 2,942