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

System bell/beep/speaker percent resets to 50 on Caps Lock, Num Lock and Scroll Lock #394

Open
dotpointer opened this issue Oct 15, 2022 · 7 comments

Comments

@dotpointer
Copy link

dotpointer commented Oct 15, 2022

Expected behaviour

The system bell percent is not changed when the keyboard keys Caps Lock, Num Lock (and Scroll Lock if enabled) keys are used when mate-settings-daemon runs.

Actual behaviour

The bell percent is set to 50 when Caps Lock, Num Lock (and Scroll Lock if enabled) are used when mate-settings-daemon runs.

Maybe more keys are affected.

This issue has been directly reproduced on 2 hosts.

Steps to reproduce the behaviour

In MATE Desktop - Example 1:

Start a MATE Desktop session.
Open a MATE Terminal window.
Run xset b 0 to set bell percent to 0.
Run xset q|grep bell to verify that the bell percent is 0.
Press and release Caps Lock or Num Lock (or Scroll Lock if enabled).
Run xset q|grep bell, note that it has changed to 50.

In MATE DESKTOP - Example 2, on a host that has a working system speaker:

Open a MATE Terminal window.
Run xset b 0 to set bell percent to 0.
Open MATE Calculator, by the menus or by pressing ALT+F2 and typing mate-calc and then press Enter.
Press Num Lock, Caps Lock (or Scroll Lock if enabled), then Backspace.
Listen for the system speaker beep.

In Plasma with mate-settings-daemon:

Start a Plasma desktop session.
Open a MATE Terminal window.
Run xset b 0 to set bell percent to 0.
Run xset q|grep bell to verify that the bell percent is 0.
Press and release Caps Lock or Num Lock, or Scroll Lock.
Run xset q|grep bell, note that it still is 0.
Run mate-settings-daemon.
Press and release Caps Lock or Num Lock, or Scroll Lock.
Run xset q|grep bell, note that it has changed to 50.

Also try the above steps with an initial percent other than 0, for example 100. It resets to 50 too.

To enable Scroll Lock run this in a terminal window:
xmodmap -e 'add mod3 = Scroll_Lock'

Outcome of this issue

Frustration, the system speaker makes unwanted beeps in programs like the MATE Calculator, the browser, the MATE Terminal and more because the volume keeps resetting on each Caps Lock, Num Lock and Scroll Lock use.

MATE general version

1.24.1

Package version

1.24.1-1

Linux Distribution

Debian GNU/Linux 11 (bullseye)

@lukefromdc
Copy link
Member

lukefromdc commented Nov 5, 2022

I was able to duplicate this behavior for the Num Lock key but NOT the Caps Lock key on my setup, Scroll Lock did nothing but may be nonfunctional here. With numlock, turning it on or off did indeed reset the reading from
xset q|grep bell
to 50 thus confirming the issue. System differences no doubt are why I don't get it in caps lock or scroll lock, implying this might not be seen at all by some users, on all three and possibly more keys by others.

Note that you do NOT need functional system sounds-or even sound support at all-to test this. On my system the bell is never heard (no "PC speaker" only the normal (and more recent in PC evolution) audio outputs are hooked up, and I have "system sounds" set to "No Sounds" in sound preferences. System sound does not work if I try to turn it on,no sounds installed and possibly other isues.

@lukefromdc
Copy link
Member

On further testing, I found that xset b off also is overridden by the Num Lock key here

@lukefromdc
Copy link
Member

lukefromdc commented Nov 5, 2022

Bell output is to "pc speaker" and should not be heard in headphones/external/laptop speakers
https://wiki.archlinux.org/title/PC_speaker
This is a legacy speaker dating back to the very first IBM PC's, still useful in diagnosing some BIOS and presumably UEFI issues. It can be disconnected, silencing the bell.
Also note that to this date, nobody has figured out a way to redirect the bell to the real speakers and then posted it to the Xorg documentation:
https://www.x.org/wiki/FAQMiscellaneous/#index7h2

As for the origin of the bell itself, my guess is the first keyboard computer terminals (which predated even use of a CRT) inherited it from TYPEWRITERS, where it was used to warn the typist of the right margin. That makes it possibly 140 years old!

@lukefromdc
Copy link
Member

Also check out these possible ways to turn it off, from
https://wiki.archlinux.org/title/PC_speaker:

Globally

The PC speaker can be disabled by unloading the pcspkr kernel module:
Note: This will not disable your entire sound system, only the PC speaker.

rmmod pcspkr

Blacklisting the pcspkr module will prevent udev from loading it at boot. Create the file:

/etc/modprobe.d/nobeep.conf

blacklist pcspkr

Blacklisting it on the kernel command line is yet another way. Simply add modprobe.blacklist=pcspkr to your bootloader's kernel line.
Console

You can add this command in /etc/profile or a dedicated file like /etc/profile.d/disable-beep.sh:

setterm -blength 0

Another way is to uncomment or add this line in /etc/inputrc or ~/.inputrc:

set bell-style none

@dotpointer
Copy link
Author

dotpointer commented Nov 15, 2022

This bug is new, I have not had it in previous versions (of Debian). I would have noticed - it beeps very annoyingly.

This enables the Scroll Lock key on Debian 11:
xmodmap -e 'add mod3 = Scroll_Lock'

For the time being I now use the following workaround that sets the bell to 0 every minute if it is not 0:

/etc/crontab:
* * * * * <my-username> /bin/bash /path/to/shutup.sh

/path/to/shutup.sh:

#!/bin/bash
export DISPLAY=':0.0';
xset q|grep "bell percent:  0" > /dev/null
if [[ $? -ne 0 ]]; then
  setterm -blength 0 > /dev/null 2>&1
  setterm -bfreq 0 > /dev/null 2>&1
  xset b off > /dev/null 2>&1
fi

@dotpointer
Copy link
Author

This bug affects standard HP EliteBook laptops such as those in the G3 series and probably many other. Not only exotic special systems.

Press Num Lock in MATE Desktop, then open an application that uses the bell such as MATE Calculator or MATE Terminal and press backspace and it beeps.

@lukefromdc
Copy link
Member

lukefromdc commented Dec 14, 2022 via email

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

No branches or pull requests

2 participants