5ac0e953bc281f6a7f945f160ed42a9d55cb09f1
[dotfiles-public.git] / src / .bashrc.d / 20nobeep
1 # turn off terminal beep in X
2 if [ -n "$DISPLAY" ] && [ "$TERM" == "xterm" ]; then
3         if [ -x "$(command -v xset)" ]; then
4                 xset b off
5         fi;
6 fi
7
8 # turn of terminal beeps in the console, unless connecting via SSH
9 if [ -n "$TERM" ] && [ -z "$SSH_CLIENT" ]; then
10         setterm --blength 0 2>/dev/null || setterm -blength 0
11 fi
12
13 # turn off beeps in Firefox
14 if [ -f ~/.mozilla/firefox/profiles.ini ]; then
15         for PROFILE in $(sed -n 's/Path=//p' ~/.mozilla/firefox/profiles.ini); do
16                 PREFERENCES=~/.mozilla/firefox/"${PROFILE}"/user.js
17                 if [ -f "${PREFERENCES}" ]; then
18                         if grep accessibility.typeaheadfind.enablesound "${PREFERENCES}" >/dev/null; then
19                                 sed -i 's/\("accessibility.typeaheadfind.enablesound"\)[^)]*/\1, false/' "${PREFERENCES}"
20                         else
21                                 echo 'user_pref("accessibility.typeaheadfind.enablesound", false);' >>"${PREFERENCES}"
22                         fi
23                 else
24                         echo 'user_pref("accessibility.typeaheadfind.enablesound", false);' >>"${PREFERENCES}"
25                 fi
26         done
27 fi