XkbDeviceBell(3)
π XkbDeviceBell(3) β XKB FUNCTIONS π
okay so bestie, this is the XkbDeviceBell(3) page from XKB FUNCTIONS β manual name folded in right at the top like a little bow π. Itβs giving βring the bell on an X input extension device or the default keyboardβ energy, and honestly? iconic. periodt.
π NAME π
XkbDeviceBell β Rings the bell on an X input extension device or the default keyboard.
β¨ SYNOPSIS β¨
Bool XkbDeviceBell (Display *display, Window window, unsigned int
device_spec, unsigned int bell_class, unsigned int bell_id, int
percent, Atom name);
πΈ ARGUMENTS πΈ
displayβ connection to the X serverwindowβ window for which the bell is generated, orNonedevice_specβ device ID, orXkbUseCoreKbdbell_classβ X input extension bell class of the bell to be rungbell_idβ X input extension bell ID of the bell to be rungpercentβ bell volume, from-100to100inclusivenameβ a name for the bell, orNULL
π DESCRIPTION π
The core X protocol allows only applications to explicitly sound the system bell with a given duration, pitch, and volume. Xkb extends this capability by allowing clients to attach symbolic names to bells, disable audible bells, and receive an event whenever the keyboard bell is rung. For the purposes of this document, the audible bell is defined to be the system bell, or the default keyboard bell, as opposed to any other audible sound generated elsewhere in the system. You can ask to receive XkbBellNotify events when any client rings any one of the following:
- The default bell
- Any bell on an input device that can be specified by a
bell_classandbell_idpair - Any bell specified only by an arbitrary name. (This is, from the server's point of view, merely a name, and not connected with any physical sound-generating device. Some client application must generate the sound, or visual feedback, if any, that is associated with the name.)
You can also ask to receive XkbBellNotify events when the server rings the default bell or if any client has requested events only (without the bell sounding) for any of the bell types previously listed.
You can disable audible bells on a global basis. For example, a client that replaces the keyboard bell with some other audible cue might want to turn off the AudibleBell control to prevent the server from also generating a sound and avoid cacophony. If you disable audible bells and request to receive XkbBellNotify events, you can generate feedback different from the default bell.
You can, however, override the AudibleBell control by calling one of the functions that force the ringing of a bell in spite of the setting of the AudibleBell control β XkbForceDeviceBell or XkbForceBell. In this case the server does not generate a bell event.
Just as some keyboards can produce keyclicks to indicate when a key is pressed or repeating, Xkb can provide feedback for the controls by using special beep codes. The AccessXFeedback control is used to configure the specific types of operations that generate feedback.
π¦ Bell Names π¦
You can associate a name to an act of ringing a bell by converting the name to an Atom and then using this name when you call the functions listed in this chapter. If an event is generated as a result, the name is then passed to all other clients interested in receiving XkbBellNotify events. Note that these are arbitrary names and that there is no binding to any sounds. Any sounds or other effects (such as visual bells on the screen) must be generated by a client application upon receipt of the bell event containing the name. There is no default name for the default keyboard bell. The server does generate some predefined bells for the AccessX controls. These named bells are shown in Table 1; the name is included in any bell event sent to clients that have requested to receive XkbBellNotify events.
Table 1 Predefined Bells β columns: Action β Named Bell
- Indicator turned on β
AX_IndicatorOn - Indicator turned off β
AX_IndicatorOff - More than one indicator changed state β
AX_IndicatorChange - Control turned on β
AX_FeatureOn - Control turned off β
AX_FeatureOff - More than one control changed state β
AX_FeatureChange - SlowKeys and BounceKeys about to be turned on or off β
AX_SlowKeysWarning - SlowKeys key pressed β
AX_SlowKeyPress - SlowKeys key accepted β
AX_SlowKeyAccept - SlowKeys key rejected β
AX_SlowKeyReject - Accepted SlowKeys key released β
AX_SlowKeyRelease - BounceKeys key rejected β
AX_BounceKeyReject - StickyKeys key latched β
AX_StickyLatch - StickyKeys key locked β
AX_StickyLock - StickyKeys key unlocked β
AX_StickyUnlock
π«Ά Audible Bells π«Ά
Using Xkb you can generate bell events that do not necessarily ring the system bell. This is useful if you need to use an audio server instead of the system beep. For example, when an audio client starts, it could disable the audible bell (the system bell) and then listen for XkbBellNotify events. When it receives a XkbBellNotify event, the audio client could then send a request to an audio server to play a sound.
You can control the audible bells feature by passing the XkbAudibleBellMask to XkbChangeEnabledControls. If you set XkbAudibleBellMask on, the server rings the system bell when a bell event occurs. This is the default. If you set XkbAudibleBellMask off and a bell event occurs, the server does not ring the system bell unless you call XkbForceDeviceBell or XkbForceBell.
Audible bells are also part of the per-client auto-reset controls.
π Bell Functions π
Use the functions described in this section to ring bells and to generate bell events.
The input extension has two types of feedbacks that can generate bells β bell feedback and keyboard feedback. Some of the functions in this section have bell_class and bell_id parameters; set them as follows: Set bell_class to BellFeedbackClass or KbdFeedbackClass. A device can have more than one feedback of each type; set bell_id to the particular bell feedback of bell_class type.
Table 2 Bell Sounding and Bell Event Generating β columns: Function called / AudibleBell / Server sounds a bell / Server sends an XkbBellNotifyEvent
XkbDeviceBellβ AudibleBell:On; server sounds a bell:Yes; server sends anXkbBellNotifyEvent:YesXkbDeviceBellβ AudibleBell:Off; server sounds a bell:No; server sends anXkbBellNotifyEvent:YesXkbBellβ AudibleBell:On; server sounds a bell:Yes; server sends anXkbBellNotifyEvent:YesXkbBellβ AudibleBell:Off; server sounds a bell:No; server sends anXkbBellNotifyEvent:YesXkbDeviceBellEventβ AudibleBell:On or Off; server sounds a bell:No; server sends anXkbBellNotifyEvent:YesXkbBellEventβ AudibleBell:On or Off; server sounds a bell:No; server sends anXkbBellNotifyEvent:YesXkbDeviceForceBellβ AudibleBell:On or Off; server sounds a bell:Yes; server sends anXkbBellNotifyEvent:NoXkbForceBellβ AudibleBell:On or Off; server sounds a bell:Yes; server sends anXkbBellNotifyEvent:No
Set percent to be the volume relative to the base volume for the keyboard as described for XBell.
Note that bell_class and bell_id indicate the bell to physically ring. name is simply an arbitrary moniker for the client application's use.
To determine the current feedback settings of an extension input device, use XGetFeedbackControl. See the X input extension documentation for more information on XGetFeedbackControl and related data structures.
If a compatible keyboard extension is not present in the X server, XkbDeviceBell immediately returns False. Otherwise, XkbDeviceBell rings the bell as specified for the display and keyboard device and returns True. If you have disabled the audible bell, the server does not ring the system bell, although it does generate a XkbBellNotify event.
You can call XkbDeviceBell without first initializing the keyboard extension.
π¦ STRUCTURES π¦
Okay bestie, so here's the tea on how the bell events actually work π
Xkb generates XkbBellNotify events for all bells... except the ones that come from calls to XkbForceDeviceBell and XkbForceBell. Like, those two are the rebellious ones that don't send an invite to the party π
So if you want to receive XkbBellNotify events under all possible conditions, you gotta pass XkbBellNotifyMask in both the bits_to_change and values_for_bits parameters when you call XkbSelectEvents. Both of them, babes. Not one. Both. β¨
The XkbBellNotify event has no event details. It's either selected or it's not β very binary of it, honestly. But!! You can call XkbSelectEventDetails using XkbBellNotify as the event_type, and specifying XkbAllBellEventsMask in bits_to_change and values_for_bits. That has the exact same effect as a call to XkbSelectEvents. Slay, same energy, different route π
The structure for the XkbBellNotify event type contains:
typedef struct _XkbBellNotify {
int type; /* Xkb extension base event code */
unsigned long serial; /* X server serial number for event */
Bool send_event; /* True => synthetically generated */
Display * display; /* server connection where event generated */
Time time; /* server time when event generated */
int xkb_type; /* XkbBellNotify */
unsigned int device; /* Xkb device ID, will not be XkbUseCoreKbd */
int percent; /* requested volume as % of max */
int pitch; /* requested pitch in Hz */
int duration; /* requested duration in microseconds */
unsigned int bell_class; /* X input extension feedback class */
unsigned int bell_id; /* X input extension feedback ID */
Atom name; /* "name" of requested bell */
Window window; /* window associated with event */
Bool event_only; /* False -> the server did not produce a beep */
} XkbBellNotifyEvent;
Note that device will not be XkbUseCoreKbd β it's a real Xkb device ID, no cap π
And here's a lil practical note for u π«Ά If your application needs to generate visual bell feedback on the screen when it receives a bell event, use the window ID in the XkbBellNotifyEvent, <italic>if present*. Like, if there's no window in there, there's nothing to draw on β check first, bestie πΈ
π SEE ALSO π
Go read these next, they're all iconic in their own way π
XBell(3)XkbBellNotify(3)XkbChangeEnabledControls(3)XkbDeviceBell(3)XkbForceBell(3)XkbForceDeviceBell(3)XGetFeedbackControl(3)XkbSelectEvents(3)
And that's the whole page, bestie!! π You ate that. This lil masterpiece is from X Version 11, specifically libX11 1.8.14, and it's the XkbDeviceBell(3) page β go forth and ring bells responsibly πβ¨ no cap, ily, bye π«Άπ
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- Copyright (c) 1999, Oracle and/or its affiliates
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms