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

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. ☺

Code, Applied to Life

Stories about how coding can be applied to solve everyday…

Thai Pangsakulyanont

Written by

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

Code, Applied to Life

Stories about how coding can be applied to solve everyday life problems. (Formerly Ruby Everyday).

Thai Pangsakulyanont

Written by

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

Code, Applied to Life

Stories about how coding can be applied to solve everyday life problems. (Formerly Ruby Everyday).

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store