1

I want to use console API of beep to produce a tone because it has lower latency than the evdev API but doing so is not permitted in a graphical shell.

Ctrl+Alt+F6 opens tty6 and after logging in I can run

beep -e /dev/tty6

In the graphical shell, tty7, you can't write to /dev/tty7 or any of the other tty files and running beep as root is prohibited.

https://github.com/spkr-beep/beep/issues/6#issuecomment-1264648890

The maintainer said here it's not a good idea for security reasons but I don't intend to use it that way for long.

Toto
  • 19,304
Deoxal
  • 113

1 Answers1

3

running beep as root is prohibited

In my Debian 10 beep 1.4.3 can be run as root.

My tests indicate beep refuses to work when there is SUDO_UID, SUDO_GID, SUDO_USER or SUDO_COMMAND in the environment. sudo sets these variables for the command it executes.

Trivia: the variables are the reason sudo -u "$USER" beep doesn't work. It's funny it doesn't work because beep here gets executed as the invoking user, like sole beep without sudo.

I can use env -u … to unset the variables, or simply env -i to clear the environment:

sudo env -i beep -e /dev/tty1

(I note I can pick any existing tty; prior logging in to the tty is not required). I'm not sure if this will help you get low latency though. sudo and env are additional programs that will add latency.

Alternatively I can invoke sudo -i and unset the variables – and then I can call beep -e … which will work as root.