BEEP(1)

πŸ“¦
version 1.4.12 Β· 5 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸŽ€ BEEP(1) β€” User commands πŸŽ€

okay bestie, welcome to the BEEP(1) manual page. It’s literally about making your PC speaker go beep, any number of ways. πŸ’–

🌸 NAME 🌸

beep β€” beep the pc speaker any number of ways.

✨ SYNOPSIS ✨

beep [GLOBALS] [-f FREQ] [-l LEN] [-r REPEATS] [<-d|-D> DELAY] [-s] [-c]
beep [GLOBALS] <TONE_OPTIONS> [-n|--new] <TONE_OPTIONS>
beep <-h|--help>
beep <-v|-V|--version>

πŸ’… DESCRIPTION πŸ’…

beep lets you control the PC speaker with precision, so different sounds can indicate different events. While beep can be run quite happily on the command line, its intended use is inside shell/perl scripts, notifying you when something interesting occurs. Of course, it has no notion of what IS interesting β€” it’s just really good at the notifying part. 🫢

All options have default values, meaning that just typing beep will work. If an option is specified more than once on the command line, subsequent options override their predecessors. So beep -f 200 -f 300 will beep at 300Hz.

All durations are given in a unit of milliseconds, frequencies as Hertz, and the number of repeats is a dimensionless number. ✨

🌈 OPTIONS 🌈

🌟 Global options 🌟

  • -e DEVICE, --device=DEVICE β€” Explicitly set the device beep shall use to generate beep tones. When not given a device explicitly, beep runs through an internal list of devices until one appears to work.
  • --debug, --verbose β€” Make the beep program more verbose.

🎡 Tone options 🎡

  • -f FREQ β€” Beep with a tone frequency of FREQ Hz, where 0 < FREQ < 20000. As a general ballpark, the regular terminal beep is around 750Hz. For backwards compatibility, you can give FREQ as a floating point number, but beep will round that to integer values as the kernel APIs expect them. Default value: 440 Hz.
  • -l LEN β€” Beep for a tone length of LEN milliseconds. Default value: 200 ms.
  • -r REPEATS β€” Repeat the tone including delays REPEATS times. Default value: 1 tone, not repeated.
  • -d DELAY | -D DELAY β€” Specify a delay of DELAY milliseconds between repetitions. Small letter -d specifies that this delay should only occur between beeps, that is, it should not occur after the last repetition. Capital letter -D specifies that the delay should occur after every repetition, including after the last one. Normally, -d is what you want, but if, for example, you are stringing several beep commands together to play the star wars anthem, you may want control over every delay. Default value: 100 ms delay between beeps with no delay after the last beep.
  • -n, --new β€” The --new option allows you to chain multiple beeps together on a single command line. Each time the --new is used, beep starts treating all further arguments as though they were for a new beep. So for example:
beep -f 1000 -n -f 2000 -n -f 1500

would produce a sequence of three beeps, the first with a frequency of 1000Hz (and otherwise default values), then a second beep with a frequency of 2000Hz (again, with things like delay and reps being set to their defaults), then a third beep, at 1500Hz. This is different from specifying a -r value, since -r repeats the same beep multiple times, whereas --new allows you to specify different beeps. After a --new, the new beep is created with all the default values, and any of these can be specified without altering values for preceding (or later) beeps. See the EXAMPLES section if this managed to confuse you.

  • -s, -c β€” Both the -s and the -c option put beep into input processing mode, reading from stdin and copying all received data to stdout. This makes it easy to slip beep into a text processing pipeline to acoustically monitor the data flow within that pipeline. See the EXAMPLES section.
    • -c β€” Beep after every character received.
    • -s β€” Beep after every set of data received. Usually, this means after newlines occur in text processing pipes.

In a sequence of notes specified with one or more occurrences of -n or --new, it only makes sense to have one single note marked with either -s or -c attached to it. Then beep will beep all notes until it reaches that marked note, then repeat the marked note according to the input it receives, and once the input has reached EOF, beep will continue with the remainder of the note sequence.

The behaviour of beep with more than one note marked with -s or -c is undefined. πŸ’€

πŸ›ŽοΈ Other Actions πŸ›ŽοΈ

  • -h, --help β€” Display beep usage info and exit.
  • -v, -V, --version β€” Display beep version information and exit.

βœ… EXIT STATUS βœ…

When successful, beep returns with exit code 0.

Any non-0 exit code means beep has encountered an error and has bailed out.

🌱 ENVIRONMENT 🌱

  • BEEP_LOG_LEVEL β€” When set to a number between -999 and 999, BEEP_LOG_LEVEL will be used as the default loglevel until overridden by a command line parameter.

πŸ“ FILES πŸ“

The device files beep uses by default are the following:

/dev/input/by-path/platform-pcspkr-event-spkr
/dev/tty0
/dev/vc/0

🧚 NOTES 🧚

πŸ› οΈ Devices and Permissions πŸ› οΈ

When you run beep without explicitly giving a device to use, beep tries opening the following devices in sequence until one succeeds:

  • /dev/input/by-path/platform-pcspkr-event-spkr β€” Uses the evdev API, and the system administrator can allow access to any set of users and groups using the normal file permissions.
  • /dev/tty0 β€” Uses the console API, and the kernel insists you are root or own the TTY.
  • /dev/vc/0 β€” Uses the console API, and the kernel insists you are root or own the TTY.
beep does not support running as setuid root or via sudo(1).

For non-root uses, the system administrator can set up a udev(7) rule to allow write access to /dev/input/by-path/platform-pcspkr-event-spkr for certain users and/or user groups. For details, see the beep /usr/share/doc/beep/PERMISSIONS.md file.

🧠 APIs 🧠

evdev

Uses the input event device driver, which means running write(2) on /dev/input/by-path/platform-pcspkr-event-spkr.

The permissions to this device file can be set up such that beep can be run by any non-root user the system administrator wants to.

Opening this device takes on the order of magnitude of 20ms in the Linux kernel for every time you start the beep command. Therefore, if you need to play multiple notes in a rhythmical sequence for a melody, use one beep command invocation with multiple notes, not several beep invocations playing one note each. πŸ”₯

console

Uses the ancient console API, which means running the KIOCSOUND ioctl(2) on a tty device like /dev/tty0 or /dev/vc/0.

This requires being root, unless the non-root user happens to be logged into the virtual console and be using that specific virtual console device like e.g. /dev/tty4. This makes the console driver useless for non-root users logged in via ssh, and often X11 or Wayland.

Use the evdev API instead.

⚠️ Concurrent Invocations ⚠️

Concurrent invocations of beep are not supported. There is only one tone generator in the PC hardware, and we do not manage access to that shared resource in any way. So if a first beep -f 1000 -l 10000 process starts a long 10 second beep with 1000Hz, and 2 seconds later a second quick beep -f 2050 -l 100 with 2050Hz comes in, you will hear that 2050Hz beep for 100ms, and then silence as the quick beep silences the tone generator. Now you will not hear that the first beep process is still running after having waited for the first 2100ms of its 10000ms. You will also not hear that the first beep process will silence the already silent speaker 7900ms later, i.e. 10000ms after the first beep started.

πŸ”Š Sound Volume πŸ”Š

The PC speaker hardware has no way to explicitly set the volume of a beep.

If you have a standalone PC, however, chances are you have a piezo beeper connected to the mainboard. If you prioritize a loud beep over a certain frequency beep, you can choose to beep at a frequency close to the resonance frequency of the piezo beeper. Typical piezo beepers have a resonance frequency around 2000Hz, so you can test frequencies around that range. The author’s piezo beeper is the loudest at about 2050Hz.

If you have a PC laptop, chances are that your laptop will not have a piezo beeper hardware inside and that it will route the output of the pcspkr circuit to the laptop’s internal speakers via the sound card mixer. In that case, you can and/or must change the mixer level for the beeper using a sound card mixer application.

🎢 Frequency Table 🎢

This frequency table might come in handy for translating musical notes to frequencies. The frequencies are rounded to integer numbers as the kernel driver only works with integers. The column for octave 4 is the octave of middle C.

The octaves are 3, 4, 5, and 6, bestie:

  • C β€” octave 3: 131; octave 4: 262; octave 5: 523; octave 6: 1047
  • C# β€” octave 3: 139; octave 4: 277; octave 5: 554; octave 6: 1109
  • D β€” octave 3: 147; octave 4: 294; octave 5: 587; octave 6: 1175
  • D# β€” octave 3: 156; octave 4: 311; octave 5: 622; octave 6: 1245
  • E β€” octave 3: 165; octave 4: 330; octave 5: 659; octave 6: 1319
  • F β€” octave 3: 175; octave 4: 349; octave 5: 698; octave 6: 1397
  • F# β€” octave 3: 185; octave 4: 370; octave 5: 740; octave 6: 1480
  • G β€” octave 3: 196; octave 4: 392; octave 5: 784; octave 6: 1568
  • G# β€” octave 3: 208; octave 4: 415; octave 5: 831; octave 6: 1661
  • A β€” octave 3: 220; octave 4: 440; octave 5: 880; octave 6: 1760
  • A# β€” octave 3: 233; octave 4: 466; octave 5: 932; octave 6: 1865
  • B β€” octave 3: 247; octave 4: 494; octave 5: 988; octave 6: 1976
  • C β€” octave 3: 262; octave 4: 523; octave 5: 1047; octave 6: 2093

πŸ› BUGS πŸ›

Report bugs to https://github.com/spkr-beep/beep/issues.

✨ EXAMPLES ✨

okay bestie, this is where it gets fun β€” here are the example vibes, and yes, copy the commands exactly, no cap πŸ’…

🌱 At its simplest (yet still effective)

literally just:

beep

πŸŽ€ A more interesting standalone setup

this one’s giving standalone main-character energy:

beep -f 300.7 -r 2 -d 100 -l 400

πŸ¦‹ As part of a log watching pipeline

when you’re watching logs and want a beep in the mix:

tail -f /var/log/xferlog | grep 'passwd' | beep -f 1000 -r 5 -s

πŸ“ When using -c mode

okay so when you’re using -c mode, I lowkey recommend a short -D, and a shorter -l, so that the beeps do not blur together. Something like this will get you a cheesy 1970's style beep-as-you-type-each-letter effect:

cat file | beep -c -f 400 -D 50 -l 10

πŸ’€ A highly contrived example of -n/--new usage

this one is highkey contrived, but it slaps:

beep -f 1000 -r 2 -n -r 5 -l 10 --new

it will produce first two 1000Hz beeps, then 5 beeps at the default tone, but only 10ms long each, followed by a third beep using all the default settings (since none are specified). periodt ✨

πŸ‘€ SEE ALSO πŸ‘€

check these out too, bestie:


okay that’s the whole BEEP(1) page β€” Linux, dated 2020-01-01 πŸŽ€πŸ’–πŸ«Ά