Bug 58930 - X11 bell event dropped in Xfce and other non-Gnome desktops
Summary: X11 bell event dropped in Xfce and other non-Gnome desktops
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-02 01:51 UTC by PMouse
Modified: 2018-07-30 10:32 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description PMouse 2013-01-02 01:51:14 UTC
When running Xfce (or any other non-GNOME-based desktop), the X11 bell event generated by XTerm and some terminal emulators does not produce any audible sound; it is lost, dropped, or ignored somewhere.

Steps to Reproduce:
1.  Install xterm
2.  Start xterm
3.  type 'echo ^G' <ENTER>
4.  Or, install the 'xkbbell' utility and run it, or run xbiff, irssi, or any program that makes a bell/beep.  (Hell, even firefox makes this beep if you search for a word that doesn't exist on the page.)

Please see https://bugzilla.redhat.com/show_bug.cgi?id=607393 for (the very long) history.
Comment 1 Vincent Untz 2013-01-07 07:48:58 UTC
Moving to PA, as intended (see the redhat bug).
Comment 2 Daniel Hahler 2014-11-07 00:34:43 UTC
I have noticed that pulseaudio fails to fall back to properly:

    I: [pulseaudio] module-x11-bell.c: Ringing bell failed, reverting to X11 device bell.

The code is the following (in x11_event_cb, src/modules/x11/module-x11-bell.c):

    if (pa_scache_play_item_by_name(u->core, u->scache_item, u->sink_name, ((pa_volume_t) bne->percent*PA_VOLUME_NORM)/100U, NULL, NULL) < 0) {
        pa_log_info("Ringing bell failed, reverting to X11 device bell.");
        XkbForceDeviceBell(pa_x11_wrapper_get_display(w), bne->device, bne->bell_class, bne->bell_id, bne->percent);
    }

It looks like XkbForceDeviceBell is meant to do beeping via the pcspkr module?!


The problem is that the module-x11-bell module gets loaded always via /usr/bin/start-pulseaudio-x11:

   /usr/bin/pactl load-module module-x11-bell "display=$DISPLAY" "sample=bell.ogg" > /dev/null

But the sample is not being uploaded.

You can check if the module is loaded using:

    pactl list | grep module-x11-bell

The sample can be loaded manually using:

    pactl upload-sample /usr/share/sounds/gnome/default/alerts/glass.ogg bell.ogg

Does uploading a (valid, existing) sample file work for you?
Comment 3 Daniel Hahler 2014-11-07 00:38:43 UTC
I am using Ubuntu (14.04), with awesome window manager, but the basic Gnome environment (e.g. gnome-settings-daemon).

The same applies to a guest session, which uses Ubuntu's Unity: after module-x11-bell is loaded (without a sample), the regular pcspkr beeping disappears.
Comment 4 Daniel Hahler 2014-11-07 02:14:36 UTC
I have sent the following patch to the mailing list, which fixes it for me:


> From a9bbcf5f130fcba4420325a7ec0a87ba3ca0e2b8 Mon Sep 17 00:00:00 2001
> From: Daniel Hahler <git@thequod.de>
> Date: Fri, 7 Nov 2014 02:56:43 +0100
> Subject: [PATCH] module-x11-bell: use XkbUseCoreKbd in XkbForceDeviceBell
>  fallback
>
> bne->device is 3, but that caused no beep/bell. Using XkbUseCoreKbd
> fixes it for me.
>
> In case `XkbForceDeviceBell` would return false (which it did not), a
> warning gets logged now.
>
> Ref: https://bugs.freedesktop.org/show_bug.cgi?id=58930
> ---
>  src/modules/x11/module-x11-bell.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/modules/x11/module-x11-bell.c b/src/modules/x11/module-x11-bell.c
> index 001732b..566b0b6 100644
> --- a/src/modules/x11/module-x11-bell.c
> +++ b/src/modules/x11/module-x11-bell.c
> @@ -80,7 +80,9 @@ static int x11_event_cb(pa_x11_wrapper *w, XEvent *e, void *userdata) {
>
>      if (pa_scache_play_item_by_name(u->core, u->scache_item, u->sink_name, ((pa_volume_t) bne->percent*PA_VOLUME_NORM)/100U, NULL, NULL) < 0) {
>          pa_log_info("Ringing bell failed, reverting to X11 device bell.");
> -        XkbForceDeviceBell(pa_x11_wrapper_get_display(w), bne->device, bne->bell_class, bne->bell_id, bne->percent);
> +
> +        if (!XkbForceDeviceBell(pa_x11_wrapper_get_display(w), XkbUseCoreKbd, bne->bell_class, bne->bell_id, bne->percent))
> +            pa_log_warn("Falling back to XkbForceDeviceBell failed!");
>      }
>
>      return 1;
> --
> 2.1.0
Comment 5 PMouse 2014-11-07 04:54:05 UTC
Thanks for looking into this!

Hmm, yes, I think so.  I'm not sure because it's been an while since I looked into this problem.  Let me try to recap...

I run this code very time my X-session starts:

pactl upload-sample /usr/share/sounds/freedesktop/stereo/window-attention.oga x11-bell
pactl load-module module-x11-bell sample=x11-bell
xset b 100


I've been doing this for a couple years now and many different fix-ups before that for this problem which started so very long ago.  So, yes, I think that is exactly the work-around I've been using.  (Is my command wrong, though?  I'm not quite using the same sytanx you posted.  Your corrections appreciated.)

However, I don't know why you say module-x11-bell "always" gets loaded.  There is no reference to module-x11-bell in *my* /usr/bin/start-pulseaudio-x11 script.  (Distro-specific non-standard modification, perhaps?  Old code?)  And, as you see from my script above, I must load that module manually, myself, after my session starts; otherwise, upload-sample doesn't fix the problem by istelf (IIRC).  The module is loaded, now, on my system:

$ pactl list|grep module-x11-bell                              
        Name: module-x11-bell

but, I assume that is because my script loaded it.  I am not confident only because it's been a while and I haven't bothered to try other things.  But, that's what I remember.

Let me know if I can help.
Comment 6 Daniel Hahler 2014-11-10 22:12:11 UTC
> However, I don't know why you say module-x11-bell "always" gets loaded.  There is no reference to module-x11-bell in *my* /usr/bin/start-pulseaudio-x11 script.

Yes, this is a Ubuntu specific patch, which loads module-x11-bell, but does not upload the sample.


So, without your custom code, where the x11-bell module gets loaded, you should have the default bell, don't you?
(maybe "xset b 100" is needed)
Comment 7 PMouse 2014-11-15 21:18:14 UTC
(In reply to Daniel Hahler from comment #6)
> So, without your custom code, where the x11-bell module gets loaded, you
> should have the default bell, don't you?
> (maybe "xset b 100" is needed)

No, definitely not.  That's why I filed this bug.

What do you mean by 'default' bell?  If you mean PC speaker noise, then that may no work--I mean, that is not reliable--because pc speaker kernel module hasn't been loaded for many years (by default).
Comment 8 GitLab Migration User 2018-07-30 10:32:52 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/499.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.