Geekosopher

Yet Another Blog by Nitesh Mistry

Entries tagged "alarm"

Computer as an Alarm Clock?
24th September 2010

We all like to wake up listening to good music instead of blaring noise of alarm clock or mobile phones. And, when it comes to sleep, if you are as much like Kumbhakarna as I am, chances are that you hit the snooze/stop button even without opening the eyes and sleep for another hour.

So I was always looking for a solution, where I could set my computer as an alarm clock, and play my favourite song or playlist to wake me up. This way I will have to get out of my bed and come to the desk to stop it, by which time I would have gained my senses. Similar question was also asked by someone in Mumbai Linux Users Group mailing list some time ago (I am not able to locate the exact thread right now).

But there was a two part problem in doing this:
One - I did not want to keep my computer switched on the whole night (you know how hip it is to be 'green' now-a-days); and
Two - How to play the songs without creating the security/privacy issue of making the computer log in to my user-space automatically.

But for linux users, no problem is too big to be solved.

First problem got solved when I came accross this great article by Mechatotoro. Until I read his post I was completely ignorant of a nifty feature residing in my computer's BIOS. To enter the BIOS settings, press DEL key (or depending on your computer make, F2 or F12 key) immediately after pressing the power button of the computer. On this white-and-blue screen, navigate to the Power Management Setup section. Now go to Resume by Alarm option and select Enabled. Set the day and time field immediately below that. Press F10 key and when prompted to save the settings press Y and Enter.

That is it and now the computer will automatically get powered on at the set day and time. Ofcourse I will need to keep the main power switch on, as I am using a desktop computer. No need to worry about this if you are using a laptop.

Now the second problem. One reason why I did not want to use Mechatotoro's solution as-it-is, was that, that involved setting up auto-login. How to play the songs without setting auto-login on the computer as it is a potential security and privacy hazard. Thankfully, most linux operating systems (including Ubuntu) have a nifty little feature named cron. Here all the users of the system can set up their own list of tasks to be executed automatically at the specified date and time. For example, fetching mails from the remote server every 5 minutes, or as in my case, play the specified song at a particular time of the day.

But using cron has a small little problem. While it can let any graphical audio players play the songs when the user is logged in, it cannot do so if the user is not logged in. In my case, since I would be asleep when the computer starts in the morning, I will not be able to feed in the password for my account to let cron play the songs. So I turned to my friends at Mumbai Linux Users Group for help and as expected, they pitch in right away. The problem it seemed was that, not all audio players can play songs without user being logged in. After many trials and errors, I was suggested to try mpg123, and it worked!

So here's how to put down the second problem:

Dan-te-naaaan! I am all set to wake up in the morning and do Pranayaam and Sudarshan Kriya. No more excuses.

Oh, but how do I stop the song?
Option 1 - Enter my password to log in to the computer > Fire up a terminal > type killall mpg123
Option 2 - Oh, I have a multimedia keyboard! So I just press the mute button.
Option 3 - Why should I stop it at all. Thats my favourite song, isn't it? I enjoy it while I brush my teeth and have morning cuppa.

So all you lazy bones, you have one less excuse to not get up in the morning.

Email comments to Nitesh Mistry   Tags: alarm, auto-power-on, bios, cron, geekosophy, howto, linux, mpg123.