Option to disable audio bell

This commit is contained in:
Kovid Goyal 2017-02-14 08:10:00 +05:30
parent d96c7d71a7
commit f7cb3e3f9e
3 changed files with 10 additions and 5 deletions

View File

@ -160,6 +160,7 @@ type_map = {
'window_border_width': float, 'window_border_width': float,
'wheel_scroll_multiplier': float, 'wheel_scroll_multiplier': float,
'visual_bell_duration': float, 'visual_bell_duration': float,
'enable_audio_bell': to_bool,
'click_interval': float, 'click_interval': float,
'mouse_hide_wait': float, 'mouse_hide_wait': float,
'cursor_blink_interval': float, 'cursor_blink_interval': float,

View File

@ -91,6 +91,9 @@ repaint_delay 10
# seconds. Set to zero to disable. # seconds. Set to zero to disable.
visual_bell_duration 0.0 visual_bell_duration 0.0
# Enable/disable the audio bell. Useful in environments that require silence.
enable_audio_bell yes
# The modifier keys to press when clicking with the mouse on URLs to open the URL # The modifier keys to press when clicking with the mouse on URLs to open the URL
open_url_modifiers ctrl+shift open_url_modifiers ctrl+shift

View File

@ -108,11 +108,12 @@ class Window:
wakeup() wakeup()
def bell(self): def bell(self):
try: if self.opts.enable_audio_bell:
with open('/dev/tty', 'wb') as f: try:
f.write(b'\007') with open('/dev/tty', 'wb') as f:
except EnvironmentError: f.write(b'\007')
pass # failure to beep is not critical except EnvironmentError:
pass # failure to beep is not critical
if self.opts.visual_bell_duration > 0: if self.opts.visual_bell_duration > 0:
self.start_visual_bell_at = monotonic() self.start_visual_bell_at = monotonic()
glfw_post_empty_event() glfw_post_empty_event()