How to set up an alarm on Mac OS X without 3rd party applications.

Thai Pangsakulyanont
Code, Applied to Life
1 min readMay 8, 2015

So I’m sleepy, but want to make sure that I wake up on time.

For numerous times, my phone’s alarm clocks failed me. Some morning I wake up late with a notification, saying ‘missed alarm.’ My iPad, too. It would play the alarm song once before going completely silent.

And I thought, “using my laptop as an alarm might be more reliable,” but I don’t have any alarm clock app (and not in the mood of downloading one), so I thought of a quick solution:

I’ll make my laptop wait for some time, and then start playing songs in iTunes.

And here’s how:

  1. Open iTunes.
  2. Start playing a song or playlist that you want to use as an alarm sound, then pause it.
  3. Calculate how many seconds until you want the alarm to go off. For example, I want to wake up in 4 hours 45 minutes. That would be (4×60 + 45)×60 = 17100 seconds.
  4. Open Terminal.
  5. Type in the following shell script, substituting the number, then hit return.
sleep 17100; osascript -e 'tell application "iTunes" to play'

Have a good night. ☺

--

--

Thai Pangsakulyanont
Code, Applied to Life

(@dtinth) A software engineer and frontend enthusiast. A Christian. A JavaScript musician. A Ruby and Vim lover.