diff --git a/docs/changelog.rst b/docs/changelog.rst index b69d1a214..18dee8177 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -68,6 +68,8 @@ Detailed list of changes - macOS: Fix the maximized window not taking up full space when the title bar is hidden or when :opt:`resize_in_steps` is configured (:iss:`6021`) +- Linux: A new option :opt:`linux_bell_theme` to control which sound theme is used for the bell sound (:pull:`4858`) + - ssh kitten: Change the syntax of glob patterns slightly to match common usage elsewhere. Now the syntax is the same a "extendedglob" in most shells. diff --git a/kitty/desktop.c b/kitty/desktop.c index 6ea89ab3b..c366b7893 100644 --- a/kitty/desktop.c +++ b/kitty/desktop.c @@ -162,6 +162,7 @@ free_canberra_event_fields(CanberraEvent *e) { free(e->which_sound); e->which_sound = NULL; free(e->event_id); e->event_id = NULL; free(e->media_role); e->media_role = NULL; + free(e->theme_name); e->theme_name = NULL; } static void @@ -245,7 +246,7 @@ play_desktop_sound(PyObject *self UNUSED, PyObject *args) { const char *which, *event_id = "test sound"; const char *theme_name = "freedesktop"; int is_path = 0; - if (!PyArg_ParseTuple(args, "s|sp", &which, &event_id, &is_path, &theme_name)) return NULL; + if (!PyArg_ParseTuple(args, "s|sps", &which, &event_id, &is_path, &theme_name)) return NULL; play_canberra_sound(which, event_id, is_path, "event", theme_name); Py_RETURN_NONE; } diff --git a/kitty/glfw.c b/kitty/glfw.c index 3be19d0c8..0207cf6e1 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -1387,8 +1387,8 @@ ring_audio_bell(void) { #ifdef __APPLE__ cocoa_system_beep(OPT(bell_path)); #else - if (OPT(bell_path)) play_canberra_sound(OPT(bell_path), "kitty bell", true, "event", OPT(linux_bell_theme_name)); - else play_canberra_sound("bell", "kitty bell", false, "event", OPT(linux_bell_theme_name)); + if (OPT(bell_path)) play_canberra_sound(OPT(bell_path), "kitty bell", true, "event", OPT(bell_theme)); + else play_canberra_sound("bell", "kitty bell", false, "event", OPT(bell_theme)); #endif } diff --git a/kitty/options/definition.py b/kitty/options/definition.py index fc91cc8dd..c3df2242d 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -858,8 +858,8 @@ MP3 or WAV on macOS (NSSound) ''' ) -opt('linux_bell_theme_name', '__custom', - long_text='If audio bell is enabled on Linux, sets the XDG Sound Theme kitty will use to play the bell sound.' +opt('linux_bell_theme', '__custom', ctype='!bell_theme', + long_text='The XDG Sound Theme kitty will use to play the bell sound.' ' Defaults to the custom theme name used by GNOME and Budgie, falling back to the default freedesktop theme if it does not exist.' ' This option may be removed if Linux ever provides desktop-agnostic support for setting system sound themes.' ) diff --git a/kitty/options/parse.py b/kitty/options/parse.py index 71f7bf8a4..1c10b1f86 100644 --- a/kitty/options/parse.py +++ b/kitty/options/parse.py @@ -1024,8 +1024,8 @@ class Parser: def kitty_mod(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: ans['kitty_mod'] = to_modifiers(val) - def linux_bell_theme_name(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: - ans['linux_bell_theme_name'] = str(val) + def linux_bell_theme(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: + ans['linux_bell_theme'] = str(val) def linux_display_server(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: val = val.lower() diff --git a/kitty/options/to-c-generated.h b/kitty/options/to-c-generated.h index f8ee784c9..c1ea350a2 100644 --- a/kitty/options/to-c-generated.h +++ b/kitty/options/to-c-generated.h @@ -473,6 +473,19 @@ convert_from_opts_bell_path(PyObject *py_opts, Options *opts) { Py_DECREF(ret); } +static void +convert_from_python_linux_bell_theme(PyObject *val, Options *opts) { + bell_theme(val, opts); +} + +static void +convert_from_opts_linux_bell_theme(PyObject *py_opts, Options *opts) { + PyObject *ret = PyObject_GetAttrString(py_opts, "linux_bell_theme"); + if (ret == NULL) return; + convert_from_python_linux_bell_theme(ret, opts); + Py_DECREF(ret); +} + static void convert_from_python_active_border_color(PyObject *val, Options *opts) { opts->active_border_color = active_border_color(val); @@ -1119,6 +1132,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) { if (PyErr_Occurred()) return false; convert_from_opts_bell_path(py_opts, opts); if (PyErr_Occurred()) return false; + convert_from_opts_linux_bell_theme(py_opts, opts); + if (PyErr_Occurred()) return false; convert_from_opts_active_border_color(py_opts, opts); if (PyErr_Occurred()) return false; convert_from_opts_inactive_border_color(py_opts, opts); diff --git a/kitty/options/to-c.h b/kitty/options/to-c.h index abbb8cb49..fce4c8820 100644 --- a/kitty/options/to-c.h +++ b/kitty/options/to-c.h @@ -104,6 +104,10 @@ background_image(PyObject *src, Options *opts) { STR_SETTER(background_image); } static void bell_path(PyObject *src, Options *opts) { STR_SETTER(bell_path); } +static void +bell_theme(PyObject *src, Options *opts) { STR_SETTER(bell_theme); } + + static void window_logo_path(PyObject *src, Options *opts) { STR_SETTER(default_window_logo); } diff --git a/kitty/options/types.py b/kitty/options/types.py index 958a2a345..dde02d82f 100644 --- a/kitty/options/types.py +++ b/kitty/options/types.py @@ -376,7 +376,7 @@ option_names = ( # {{{ 'italic_font', 'kitten_alias', 'kitty_mod', - 'linux_bell_theme_name', + 'linux_bell_theme', 'linux_display_server', 'listen_on', 'macos_colorspace', @@ -535,7 +535,7 @@ class Options: input_delay: int = 3 italic_font: str = 'auto' kitty_mod: int = 5 - linux_bell_theme_name: str = '__custom' + linux_bell_theme: str = '__custom' linux_display_server: choices_for_linux_display_server = 'auto' listen_on: str = 'none' macos_colorspace: choices_for_macos_colorspace = 'srgb' diff --git a/kitty/state.c b/kitty/state.c index 8b69cfb1f..d06767266 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -1405,7 +1405,7 @@ finalize(void) { if (detached_windows.windows) free(detached_windows.windows); detached_windows.capacity = 0; #define F(x) free(OPT(x)); OPT(x) = NULL; - F(background_image); F(bell_path); F(default_window_logo); + F(background_image); F(bell_path); F(bell_theme); F(default_window_logo); #undef F // we leak the texture here since it is not guaranteed // that freeing the texture will work during shutdown and diff --git a/kitty/state.h b/kitty/state.h index 875f29cd4..454aa90d0 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -29,7 +29,6 @@ typedef struct { double wheel_scroll_multiplier, touch_scroll_multiplier; int wheel_scroll_min_lines; bool enable_audio_bell; - const char *linux_bell_theme_name; CursorShape cursor_shape; float cursor_beam_thickness; float cursor_underline_thickness; @@ -47,7 +46,7 @@ typedef struct { unsigned int macos_option_as_alt; float macos_thicken_font; WindowTitleIn macos_show_window_title_in; - char *bell_path; + char *bell_path, *bell_theme; float background_opacity, dim_opacity; float text_contrast, text_gamma_adjustment; bool text_old_gamma;