Alarm clock program that uses PC buzzer and rtcwake
Find a file
2026-03-05 09:16:29 +09:00
README.ja.MD 日本語ドキュメントちょっと更新、英語は待ってね 2026-02-23 04:33:39 +09:00
README.MD Added English document 2026-02-24 23:50:24 +09:00
Timer.php Merge remote-tracking branch 'origin/master' 2026-03-05 09:16:29 +09:00

PCAlarmClock

What is this?

This is a program for an alarm clock that uses the PC's buzzer. It can use the RTC to put the computer to sleep until the specified time and wake it up automatically.

How to use

Make sure a buzzer (not an audio speaker) is attached to the PC and that you can play it with the beep command. Many distributions do not automatically load the pcspkr kernel module needed to play the buzzer. Before using the program, either load it manually with modprobe or add the pcspkr module to /etc/modules. On Ubuntu and similar distributions the pcspkr module is blacklisted. Find the line that blacklists it and remove it from the blacklist. Ubuntu claims the blacklist is due to a bug, but such a bug does not actually exist—feel free to disable the blacklist. Add the user who will use the program to the audio group.

Install PHP once the hardware is ready.

The script has no commandline options; it prompts for settings sequentially. When you run it it will ask in order: Hour?, Min?, RTCWake?, Wake up PC 10 minutes before alarm rings? Enter the hour and minute you want the alarm to sound. If you want the RTC to wake the PC from suspend, answer Y to RTCWake?. If you want the PC to be powered on 10 minutes before the alarm, answer Y to Wake up PC 10 minutes before alarm rings?.

Customisation

At the top of the script youll find a section marked You can customise these variables in your favourites. Feel free to edit the following variables to suit your preferences:

  • $BUZZER_FREQ : Specifies the frequency of the buzzer in hertz. Default is 2000.
  • $BUZZER_LENGTH : Specifies the length of one buzz in milliseconds. Default is 300.
  • $BUZZER_DELAY : Specifies the silence interval between buzzes, in seconds. Default is 1. Note: this is not in milliseconds; fractional seconds are truncated.

Tips

  • If the PCs startup noise is loud, answering Y for Wake up PC 10 minutes before alarm rings? will power the PC on 10 minutes early. The startup noise can keep you from sleeping too deeply, helping you wake refreshed. Installing a HitachiLG optical drive is recommended because its poweron noise is especially loud.
  • If you enter a time that is earlier than the current time, the program will interpret it as that time tomorrow and set the timer accordingly.
  • Different buzzers have different frequencies at which they are loudest. Some are loudest at 2000 Hz, others at 2500 Hz. Many buzzers peak in the 18002600 Hz range, so this program defaults to 2000 Hz. If your device is loudest at a different frequency, adjust $BUZZER_FREQ. Conversely, you can reduce volume by setting the frequency to a quieter tone.