13

There is an option in the Sound Preferences dialog, Sound Effects tab, to toggle Alert volume mute. It works and suffices for my needs to disable the irritating system beep/bell.

However, I reinstall systems a LOT for testing purposes and would like to set this setting in a shell script so it's off without having to fiddle with a GUI. But for the life of me I can't seem to find where this can be toggled via a command line tool.

I've scanned through gconf-editor, PulseAudio's pacmd, grepped through /etc, even dug through the gnome-volume-control source code, but I am not seeing how this can be set.

I gather that gnome-volume-control has changed since a few releases ago.

Ideas?

Bryce
  • 4,710

3 Answers3

13

Hunted for this for a long while. Especially since I do not use pulseaudio and I cannot mute the alert sound from the UI (WTF!?)

This does it. Oh the sweet joy of silence!

# gsettings set org.gnome.desktop.sound event-sounds false
  • This makes no difference for the alert event sound on Ubuntu 18.04 with pulseaudio. – pts Oct 13 '20 at 23:18
6
  • Option 0: (this might be what you were looking for)

    sudo su gdm -c "gconftool-2 --set /desktop/gnome/sound/event_sounds --type bool false"
    
  • Option 1:

    Temporary:

    sudo modprobe -r pcspkr  
    

    Permanent

    echo “blacklist pcspkr” >> /etc/modprobe.d/blacklist
    
  • Option 2:

    Search for "set bell-style" in /etc/inputrc (options are none or visible)

  • Option 3:

    sudo mv -v /usr/share/sounds/ubuntu/stereo/*.ogg {*.disabled}
    
  • Option 4:

    man xset
    
  • 1
    I've actually already done that, but the Alert bell comes through the audio speakers via pulseaudio, not the on-board PC speaker (which I left unplugged in the case anyway). – Bryce Feb 09 '11 at 22:15
  • 1
    It seems to me that a few releases back this could be controlled via gconf, but I didn't see anything with gconftool-2 or gconf-editor. There is also a pacmd utility for manipulating sound settings, which seems like it should be the right tool but I can't discern what sequence of commands would result in toggling that setting. (I tried running pacmd info before and after toggling the Alert mute and diffing the output, but didn't see anything relevant.) – Bryce Feb 09 '11 at 22:18
  • Hmm, it would be nice if the downvoters said why they downvoted so I could "fix" the answer... – bumbling fool Feb 10 '11 at 15:23
  • This makes no difference for the alert event sound on Ubuntu 18.04 with pulseaudio. – pts Oct 13 '20 at 23:19
0

I wrote a script that lets me adjust volume easily using the pacmd and pactl commands. Seems to work well when I'm using a GNOME desktop, (Wayland or Xorg), and it's working on RHEL/Fedora and Ubuntu so far. I haven't tried using it with other desktops/distros, or with surround sound systems, etc.

Drop it in your path, and run it without any values to see the current volume. Alternatively set the volume by passing it a percentage. A single value sets both speakers, two values will set left, and right separately. In theory you shouldn't use a value outside of 0%-200%, but the command will let you set the volume higher than 200%, which may harm your speakers, so be careful.

[~]# volume
L    R   
20%  20% 
[~]# volume 100% 50%
[~]# volume
L    R   
100% 50% 
[~]# volume 80%
[~]# volume
L    R   
80%  80% 
#!/bin/bash

[ ! -z "$1" ] && [ $# -eq 1 ] && export LVOL="$1" && export RVOL="$1" [ ! -z "$1" ] && [ ! -z "$2" ] && [ $# -eq 2 ] && export LVOL="$1" && export RVOL="$2"

SINK=$(pacmd list-sinks | grep -e '* index:' | grep -Eo "[0-9]*$")

if [ -z "$LVOL" ] || [ -z "$RVOL" ]; then

pacmd list-sinks | grep -e '* index:' -A 20 | grep -e 'name:' -e '^\svolume:.\n' -e 'balance' --color=none

printf "%-5s%-4s\n%-5s%-4s\n" "L" "R" $(pacmd list-sinks | grep -e '* index:' -A 20 | grep -e '^\svolume:.\n' --color=none | grep -Eo "[0-9]%" | tr "\n" " " | sed "s/ $/\n/g") exit 0 elif [[ ! "$LVOL" =~ ^[0-9]%$ ]] || [[ ! "$RVOL" =~ ^[0-9]*%$ ]]; then printf "The volume should specified as a percentage, from 0%% to 200%%.\n" exit 1 elif [ "$SINK" == "" ]; then printf "Unable to find the default sound output.\n" exit 1 fi

pactl -- set-sink-volume $SINK $LVOL $RVOL

ladar
  • 121
  • 3
  • 1
    Hi! While I think that this is a nice and useful script (tested it and it works great), it doesn't really answer the question, which is about "How to disable Alert volume from the command line", not the sound volume in general. So, I would kindly suggest that you ask a new question which you can answer yourself with this script/answer! Otherwise, this answer might be deleted for not directly answering the question, and we would then lose a fine answer. Thanks for your contribution and I'm looking forward to upvoting your new Q&A! :) – BeastOfCaerbannog Apr 28 '22 at 11:26
  • It stops alerts from making noise on my setup.... – ladar May 02 '22 at 07:46
  • BeastOfCaerbannog does it need to target a different output sink on your system? – ladar May 02 '22 at 07:46
  • My point is that the script changes the global volume, not only the volume of alerts. What is the part of your script that specifically targets the alerts volume? – BeastOfCaerbannog May 02 '22 at 09:18
  • I blieve someone else mentioned it already, but: dconf write /org/gnome/desktop/sound/event-sounds false will disable. To actually control it, is system specific. On my system you can send control commands using notify-send .... – ladar May 03 '22 at 14:45
  • I should probably add that the alert volume is subordinate to the master volume. So lowering the master 20% with alerts at 100% gives you 20% volume. With master at 20%, and alerts at 20% you get 4% volume. – ladar May 03 '22 at 14:51