// file: sbbeep.c #include <stdio.h> #include <time.h> int main() { struct timespec a={0,200000000}, b={0,600000000}, c; int i, j; for (j=0; j<3; j++) { for (i=0; i<3; i++) { putchar('\a'); fflush(stdout); nanosleep(&a, &c); } nanosleep(&b, &c); } return 0; }
Compile this tiny prog with gcc -o sbbeep sbbeep.c
and move the resulting file to /usr/local/bin/sbbeep
Add something like the following to the crontab of root.
# Daily alarms at 8:57 and noon: 57 08 * * * /usr/local/bin/sbbeep > /dev/console 00 12 * * * /usr/local/bin/sbbeep > /dev/console
For unique alarms you can copy the following script to /usr/local/bin/sbsetalarm
:
#!/bin/bash # file: sbsetalarm # An alarm clock # Example usage: "sbsetalarm 17:10" or "sbsetalarm now +5 minutes" # This script accepts the same time specifications as the 'at' command, because # they are simply passed to 'at'. See "man at" for details # Check already set alarms with "atq" beeper='echo -e "\a"' # default noise maker bebeep=$(which sbbeep) if [ $? -eq 0 ] ; then beeper=$bebeep; fi # try to find a better noise maker user=$(id -nu) # get user id name ltrs=$(find /dev -name 'tty*' -user $user) # look for allowed terminals trms=$(echo $ltrs) # replace '\n' with ' ' term=${trms%% *} # take first terminal #term=$(echo $terms | cut -d' ' -f1) # take first terminal (alternative) #eval $beeper > $term # test if alarm works echo "$beeper > $term" | at "$@" # call 'at' with your timespec