#include <stdlib.h>
#include <fcntl.h>
#include <linux/kd.h>
int main(int argc, char *argv[]) {
int fd = open("/dev/tty10", O_RDONLY);
if (fd == -1 || argc != 3) return -1;
return ioctl(fd, KDMKTONE, (atoi(argv[2])<<16)+(1193180/atoi(argv[1])));
}
To compile, run:
#/> gcc -o beep beep.c
As root, run:
(root)#/> ./beep Hz Duration
First argument is frequency of the beep in Hz. The second is the duration of the beep in milliseconds. Some of my favorites include ...
When something bad happens, a low and short 100 ms flurp:
(root)#/> ./beep 300 100
When someone logs in:
(root)#/> ./beep 1000 200
If you want to see how to do this in x86 assembly, perhaps you would find this interesting.
Enjoy.


Did you find this post helpful, or at least, interesting?