Open rogerxx opened 3 years ago
Just realized, could pipe /dev/tty for input to beep, without having beep pull in additional libraries.
$ beep -c -f 750 -D 30 -l 30 < /dev/tty
However, beep is only activated on carriage return or '\n', end of line return, instead of after each key press.
You could try this in Bash
:
$ while read -n1 -r; do beep -f 750 -D 30 -l 30; done
or zsh
:
% while read -k; do beep -f 750 -D 30 -l 30; done
Just realized, could pipe /dev/tty for input to beep, without having beep pull in additional libraries.
$ beep -c -f 750 -D 30 -l 30 < /dev/tty
However, beep is only activated on carriage return or '\n', end of line return, instead of after each key press.
Perhaps beep
would need to
if (isatty(STDIN_FILENO)) {
...put STDIN_FILENO from cooked mode to raw mode...
}
and then reverse that before the beep program terminates in any way.
Probably a better way to implement key press noises would be in the keystroke processing software stack: Either inside the kernel or as a user space evdev input device driver for keyboard type devices.
A lot of care would need to be taken in that software, as that is also where you would implement a keylogger.
I've seen quite a few extravagant typewriting sound emulators using ALSA/Pulse for output, but seemingly bloated in my opinion with high resource usage, rather than using simple PC speaker beep. (eg. bucklespring program, but useless for vision impaired as the sounds are emitted upon press and release, more of a cosmetic feature rather than useful feature.)
Is there any method of providing the beep command the option for emulating a typewriter while typing within terminals?
If I'm not mistaken, the process is relatively simple, detect a keyscan press, play beep. I'm pretty sure the code is almost there using "beep -c -f 750 -D 20 -l 5", just needs to detect a keyscan press.