diff --git a/kitty/boss.py b/kitty/boss.py index e8bd55e7e..66de9e298 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1613,8 +1613,13 @@ def visual_window_select_action( self.mouse_handler = self.visual_window_select_mouse_handler else: self.visual_window_select_action_trigger(self.current_visual_select.window_ids[0] if self.current_visual_select.window_ids else 0) - if get_options().enable_audio_bell: - ring_bell(tab.os_window_id) + self.ring_bell_if_allowed(tab.os_window_id) + + def ring_bell_if_allowed(self, os_window_id: int = 0) -> bool: + if get_options().enable_audio_bell: + ring_bell(os_window_id or getattr(self.active_tab_manager, 'os_window_id', 0)) + return True + return False def visual_window_select_action_trigger(self, window_id: int = 0) -> None: if self.current_visual_select: @@ -1657,8 +1662,7 @@ def select_window_in_tab_using_overlay(self, tab: Tab, msg: str, only_window_ids selectable_windows.append((w.id, w.title)) if len(selectable_windows) < 2: self.visual_window_select_action_trigger(selectable_windows[0][0] if selectable_windows else 0) - if get_options().enable_audio_bell: - ring_bell(tab.os_window_id) + self.ring_bell_if_allowed(tab.os_window_id) return None cvs = self.current_visual_select diff --git a/kitty/session.py b/kitty/session.py index 3a12e8ee4..cf107953e 100644 --- a/kitty/session.py +++ b/kitty/session.py @@ -13,7 +13,7 @@ from .cli_stub import CLIOptions, SaveAsSessionOptions from .constants import config_dir, unserialize_launch_flag -from .fast_data_types import get_options, ring_bell +from .fast_data_types import get_options from .layout.interface import all_layouts from .options.types import Options from .options.utils import resize_window, to_layout_names, window_size @@ -467,8 +467,7 @@ def goto_session(boss: BossType, cmdline: Sequence[str]) -> None: if goto_session_history: switch_to_session(boss, goto_session_history[-1]) return - if get_options().enable_audio_bell: - ring_bell(getattr(boss.active_tab_manager, 'os_window_id', 0)) + boss.ring_bell_if_allowed() return else: for x in cmdline: