diff --git a/kitty/screen.c b/kitty/screen.c index 421818868..1e3cc4d70 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -857,12 +857,9 @@ void screen_erase_characters(Screen *self, unsigned int count) { void screen_bell(Screen UNUSED *self) { - FILE *f = fopen("/dev/tty", "w"); - static const char *bell = "\007"; - if (f != NULL) { - fwrite(bell, 1, 1, f); - fclose(f); - } + PyObject_CallMethod(self->callbacks, "bell", NULL); + if (PyErr_Occurred()) PyErr_Print(); + PyErr_Clear(); } static inline void diff --git a/kitty/window.py b/kitty/window.py index 170798274..610055cc4 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -106,6 +106,10 @@ class Window: self.write_buf = memoryview(self.write_buf.tobytes() + data) wakeup() + def bell(self): + with open('/dev/tty', 'wb') as f: + f.write(b'\007') + def update_screen(self): self.char_grid.update_cell_data() glfw_post_empty_event()