DEV Community

Cover image for houry: A Simple Python App That Beeps Every Hour

Posted on

houry: A Simple Python App That Beeps Every Hour

A few years ago, in the ‘pre-Apple-Watch’ era, I had a Casio F-91W. It was a very cheap watch, but it had a nice feature. There was a special setting that allowed it to beep every hour. And that was amazing! It was like a special notification for me to notice the moment.

Every time I heard a beep, I wondered if the thing I was doing was distracting me or helping me? In other words, that beep was very useful to me.

But then I bought the Apple Watch and the magic disappeared. I tried to find an app on my phone or laptop that would beep every hour, but could not.

So let's bring the magic back! I am going to use Python to create a little app for my computer with OS X that will make a sound every hour. Let’s go!

First, we need to teach our app to understand the time and play a sound. Google says these libraries should help with that:

import schedule
import time
from playsound import playsound
Enter fullscreen mode Exit fullscreen mode

Now let’s find the sound. Go to Soundjay and choose something you like. I chose this beep-sound and saved it to my project folder.

def beep():
Enter fullscreen mode Exit fullscreen mode

Now let’s play it every hour at 00 minutes:

Enter fullscreen mode Exit fullscreen mode

And as the documentation says, I should add this to make a loop:

while True:
Enter fullscreen mode Exit fullscreen mode

Let’s try it. Everything works fine.

Now I want to make it a standalone app for my Mac. But I don’t like it to show up in the dock or menu bar. I just want it to run in the background, so here are some magic words for the file:

from setuptools import setup

APP = ['']
    'argv_emulation': True,
    'iconfile': 'icon.icns',
    'plist': {
        'CFBundleShortVersionString': '0.2.0',
        'LSUIElement': True,

    options={'py2app': OPTIONS},
Enter fullscreen mode Exit fullscreen mode

As you can see, I created an icon for this app. Yes, you will only see it when you run this app, but I still wanted it to look nice. So I just took an emoji from Emojipedia, converted it via Anyconv, and saved it in the main folder of my project.

And the last step. To create an app, we should type this in the Terminal:

python py2app
Enter fullscreen mode Exit fullscreen mode

That’s it. Now you can find your app in the ‘dist’ folder. Do not forget to move it to the ‘Application’ folder and add it to Login Options on your Mac.

Happy houry!

Project on GitHub →

Top comments (3)

nskeip profile image
Nikita Hismatov

It would be nice to have requirements listed inside of (check out the setup function parameters), so users can have the script up and running without pip install -r requirements.txt.

skaplichniy profile image

Thanks, Nikita! I will add it soon

ssbozy profile image
Sandilya Bhamidipati

Thanks for the nice write up.