Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for typewriter effect when typing within terminal? #18

Open
rogerxx opened this issue Aug 19, 2021 · 4 comments
Open

Option for typewriter effect when typing within terminal? #18

rogerxx opened this issue Aug 19, 2021 · 4 comments

Comments

@rogerxx
Copy link

rogerxx commented Aug 19, 2021

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.

@rogerxx
Copy link
Author

rogerxx commented Aug 19, 2021

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.

@Matt-Deacalion
Copy link

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

@ndim
Copy link

ndim commented Apr 11, 2024

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.

@ndim
Copy link

ndim commented Apr 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants