If you keep your computer on all the time and are looking for a good way to wake up in the morning, this is easy. All you need is your regular music player and a sleep command. The sleep command is a built-in tool (at least in Ubuntu) that allows you to set a timer for any time (seconds, minutes, hours and days). If we combine the “sleep” command with our favorite music player and song, then we can set an alarm that will wake us up at a given time. This is how it works.
Set a Sleep Timer in Terminal
First open your terminal.
Once the Terminal is open, let’s take a look at how the “sleep” command works. Everything is very simple. To fall asleep for 10 seconds, use this command:
To sleep for 10 minutes, use this command:
– /
To sleep 10 hours, use this command:
Finally, to fall asleep for 10 days, use this command:
You can even combine commands, so if you want to sleep 5 hours and 30 minutes, you must use one “sleep†command with both times:
It’s simple! Of course, when your time is up, nothing else will happen, because all the “sleep” command is doing is counting down the amount of your sleep. To turn this alarm into a real alarm, we need to add to the command. For our music player, we will be using mplayer, but you can also easily use Totem, VLC, Banshee, or any other favorite music player.
For example, to invoke mplayer, we have to use this command:
By entering this into Terminal (replacing the actual path and name of the music file of course), we can listen to any song we want. Of course, the downside (when trying to create our alarm clock) is that the song plays right away.
Decision? Use the sleep command and our music player together. We will combine the two commands with “&&”, which will run the first command and then, only after it completes, will run the second. Our last team? Let’s say we want to sleep 8 hours:
It’s simple! The “sleep†command will wait 8 hours and then when the time is up, it will stop, allowing the second command – where the music is actually playing – to start. Instant alarm clock.
Of course, this has a couple of disadvantages. First, for many people, computers either go to sleep or go to sleep after a certain amount of time. This clearly would not suit our alarm clock. For this reason, you may need to disable power savers. Also, remember to double check your volume settings before bed. It would be bad if the sound was completely removed; the next morning you may not wake up! However, being able to set an alarm with just one command is a great way to take advantage of the Terminal; it really offers great speed, power and performance.
–