Skip to content

Instantly share code, notes, and snippets.

@benpicco
Created July 17, 2017 15:15
Show Gist options
  • Save benpicco/e24ddf674e31fec994df448d37dfbb02 to your computer and use it in GitHub Desktop.
Save benpicco/e24ddf674e31fec994df448d37dfbb02 to your computer and use it in GitHub Desktop.
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/kd.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
int fd = open("/dev/console", O_WRONLY);
if (fd < 0) {
printf("can't open console\n");
return fd;
}
if (geteuid()) {
printf("use:\n\tsudo %s\n", argv[0]);
return -1;
}
for (int t=0;;t++) {
int val = (t*(((t>>12)|(t>>8))&(63&(t>>4))));
printf("%d\n", val);
ioctl(fd, KIOCSOUND, val);
usleep(25000);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment