I was trying to switch OFF the bell, beep, or whatever the name of this odd thing is, on my laptop without speaker cut off.
There are some results ...
- X windows
Actually in X windows system it's enough to set "bell percent" option to "0" for the X server:
$ xset -b
check "bell percent" ...
$ xset q
bell percent: 0 bell pitch: 400 bell duration: 100
To make these settings permanent "xset -b" can be added to X session:
("xset b on" by the way enables bell back)
- in JDS
Run command
$ gnome-session-properties
shortcut of which normally is at Launch -> Preferences -> Desktop Preferences -> Session,
and add "xset -b" to Startup Programs.
Also in JDS it's possible to switch the bell off at X windows manager level,
go Launch -> Preferences -> Desktop Preferences -> Sound -> System Bell or call
$ gnome-sound-properties
- in CDE
Basically "xset -b" can be added to ~/.dt/sessions/sessionetc file,
refer to dtsession(1X) - "Executing Additional Commands at Session Startup" section,
however normally dtsession itself remembers "bell" settings:
$ cat ~/.dt/sessions/current/dt.settings
Dtsession*BellPercent: 0
Alternatively to "xset b" command, CDE has graphical tool:
$ dtaction SetDtBeep
which is basically a call of /usr/dt/bin/dtstyle, as far as:
$ dttypes -db ACTION -w rec_name SetDtBeep
=============== SetDtBeep ===============
loaded from localhost:/usr/dt/appconfig/types/C/dt.dt
LABEL : Beep Style Manager
ICON : DtBeep
TYPE : COMMAND
WINDOW_TYPE : NO_STDIO
EXEC_STRING : /usr/dt/bin/dtstyle -beep
ARG_COUNT : 0
- in Ice WM
"xset -b" can be put into ~/.icewm/startup script file (should have execute permission).
- Console
On console the situation is much worse, even terminfo adjustments not help ...
- get current terminal
# echo $TERM
sun
- get terminfo w.r.t. "sun" terminal
# infocmp >terminfo-sun
- remove "
bel=^G" from terminfo-sun file and then compile it
# tic terminfo-sun
- check terminfo just applied
# infocmp
# Reconstructed via infocmp from file: /usr/share/lib/terminfo/s/sun
sun|sun-color|Sun Microsystems Workstation console,
am, km, mir, msgr, xon,
cols#80, lines#34,
bold=\E[1m, clear=\f, cr=\r, cub1=\b, cud1=\n,
cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A,
dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
ed=\E[J, el=\E[K, ht=\t, ich=\E[%p1%d@, ich1=\E[@,
il=\E[%p1%dL, il1=\E[L, ind=\n, kcub1=\E[D,
kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kf1=\E[224z,
kf2=\E[225z, kf3=\E[226z, kf4=\E[227z, kf5=\E[228z,
kf6=\E[229z, kf7=\E[230z, kf8=\E[231z, kf9=\E[232z,
rev=\E[7m, rmso=\E[m, rmul=\E[m, rs2=\E[s, sgr0=\E[m,
smso=\E[7m, smul=\E[4m
- no "
bel" capability, however weird bell rings anyway ...
Partial way out is to switch the bell off in particuar applications:
- bash
Put "set bell-style none" to ~/.inputrc file
- vim
Put "set vb t_vb=" into ~/.vimrc
- less
Call less with "-q" option, or type "-q" inside less, getting "Ring the bell for errors but not at eof/bof" message.
For example it may be useful to have the following in a profile, to keep quiet man and etc. programs uses pager:
alias less='less -q'
PAGER='less -iq'
- mutt
Put "unset beep" command to ~/.muttrc
Doug Scott <dougs@truemail.co.th> sent me a note about beep parameters, that they basically located in
beep_params kernel structure, so they can be changed using modular debugger
mdb (1) on running system:
- Enter
mdb in kernel debugging mode (-k) and with write access (-w):
# mdb -kw
Loading modules: [ unix krtld genunix specfs dtrace
cpu.AuthenticAMD.15 uppc pcplusmp ufs ip sctp
usba uhci s1394 nca lofs zfs random nfs audiosup
sppp crypto ptm ipc md cpc fcip fctl fcp logindmux ]
>
- Print
beep_params data structure:
> beep_params::print -atd
fffffffffbc00000 struct beep_params [3] [
{
fffffffffbc00000 enum beep_type type = 1 (BEEP_CONSOLE)
fffffffffbc00004 int frequency = 0t900
fffffffffbc00008 int duration = 0t200
}
{
fffffffffbc0000c enum beep_type type = 2 (BEEP_TYPE4)
fffffffffbc00010 int frequency = 0t2000
fffffffffbc00014 int duration = 0
}
{
fffffffffbc00018 enum beep_type type = 0 (BEEP_DEFAULT)
fffffffffbc0001c int frequency = 0t1000
fffffffffbc00020 int duration = 0t200
}
]
- Ok,
frequency for our BEEP_CONSOLE is 900, duration is 200,
basically most "quiet" values are "-1" (max. value) for frequency and "0" for duration,
so write words "-1" (W-1) and "0" to beep_params+4 and beep_params+8 addresses correspondingly:
> beep_params+4/W-1
beep_params+4: 0x384 = 0xffffffff
> beep_params+8/W0
beep_params+8: 0xc8 = 0x00000000
Use ::formats command to print formats available, e.g.
> ::formats ! grep "^W"
W - write default radix unsigned int (4 bytes)
- Exit
mdb
> $q
Now beep should be quiet enough.
It's quite confusing, that "
duration = 0" doesn't switch bell completely off, besides
frequency = 0 causes system crash ...
If you look at the dump after this crash, you'll see a "division by 0" reason:
- check dump settings and load corresponding crash-dump to mdb:
# dumpadm
Dump content: kernel pages
Dump device: /dev/dsk/c1d0s0 (swap)
Savecore directory: /var/crash/localhost
Savecore enabled: yes
# cd /var/crash/localhost
# ls
bounds unix.0 vmcore.0
# mdb 0
Loading modules: ...
>
- view stack and disassemble two last called functions:
> $c
beep_frequency+0x13(0)
beep+0x74(1)
tem_bell+0x21(ffffffff80401c78, 0)
...
> beep_frequency+0x13::dis
beep_frequency: pushq %rbp
beep_frequency+1: movq %rsp,%rbp
beep_frequency+4: subq $0x18,%rsp
beep_frequency+8: pushq %rbx
beep_frequency+9: movq %rdi,-0x8(%rbp)
beep_frequency+0xd: movl $0x1234dc,%eax
beep_frequency+0x12: cltd
beep_frequency+0x13: idivl %edi
> beep::dis
...
beep+0x69: movl 0x4(%r14),%edi
beep+0x6d: xorl %eax,%eax
beep+0x6f: call +0x9c <beep_frequency>
...
- so, we have "
idivl %edi", where %edi comes from 0x4(%r14), which looks like beep_params[0].frequency
AFAIK it's going to be fixed in later releases.
Trackback URL: http://blogs.sun.com/vl/entry/turn_the_bell_off_on