Categories We Write About

Create an hourly chime app

Here is a simple implementation of an Hourly Chime App using Python. It plays a sound every hour, on the hour. This can be run as a background script on desktops (Windows/Linux/macOS) and easily extended to GUI or mobile platforms.

Features:

  • Plays a chime sound every hour.

  • Runs in the background using a loop.

  • Lightweight with minimal dependencies.


🐍 Python Code: Hourly Chime App

python
import time from datetime import datetime import threading import platform import os def play_sound(): system = platform.system() if system == "Windows": import winsound frequency = 1000 # Set Frequency To 1000 Hertz duration = 700 # Set Duration To 700 ms winsound.Beep(frequency, duration) elif system == "Darwin": os.system('afplay /System/Library/Sounds/Ping.aiff') # macOS default sound else: os.system('play -nq -t alsa synth 0.7 sine 1000') # Linux with sox installed def wait_until_next_hour(): now = datetime.now() seconds_until_next_hour = 3600 - (now.minute * 60 + now.second) print(f"Waiting {seconds_until_next_hour} seconds until the next chime at the top of the hour.") time.sleep(seconds_until_next_hour) def hourly_chime(): while True: play_sound() print(f"Chime at {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") time.sleep(3600) # Wait for one hour def start_chime(): wait_until_next_hour() chime_thread = threading.Thread(target=hourly_chime) chime_thread.daemon = True # Ensure it exits with the main program chime_thread.start() try: while True: time.sleep(1) # Keep the main thread alive except KeyboardInterrupt: print("Hourly Chime App stopped.") if __name__ == "__main__": print("Starting Hourly Chime App...") start_chime()

📦 Requirements:

  • Python 3.x

  • sox package for Linux (if using sound playback there):

    bash
    sudo apt-get install sox

💡 Customization Ideas:

  • Replace the default beep with an .mp3 or .wav file using pygame or playsound.

  • Add a system tray icon using pystray.

  • Extend to a GUI with tkinter or PyQt.

  • Schedule half-hour or quarter-hour chimes.

Would you like a mobile app version (Android/iOS) using Flutter or React Native?

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About