Linux: Use the system "bell" for the terminal bell
Adds libcanberra as a new dependency to play the system sound.
This commit is contained in:
parent
2e8188e89d
commit
2cfd55f3ce
@ -20,6 +20,7 @@ Run-time dependencies:
|
||||
* libpng
|
||||
* freetype (not needed on macOS)
|
||||
* fontconfig (not needed on macOS)
|
||||
* libcanberra (not needed on macOS)
|
||||
* ImageMagick (optional, needed to use the ``kitty icat`` tool to display images in the terminal)
|
||||
* pygments (optional, need for syntax highlighting in ``kitty +kitten diff``)
|
||||
|
||||
@ -28,7 +29,7 @@ Build-time dependencies:
|
||||
* gcc or clang
|
||||
* pkg-config
|
||||
* For building on Linux in addition to the above dependencies you might also need to install the ``-dev`` packages for:
|
||||
``libdbus-1-dev``, ``libxcursor-dev``, ``libxrandr-dev``, ``libxi-dev``, ``libxinerama-dev``, ``libgl1-mesa-dev``, ``libxkbcommon-x11-dev``, ``libfontconfig-dev`` and ``libpython-dev``.
|
||||
``libdbus-1-dev``, ``libxcursor-dev``, ``libxrandr-dev``, ``libxi-dev``, ``libxinerama-dev``, ``libgl1-mesa-dev``, ``libxkbcommon-x11-dev``, ``libfontconfig-dev``, ``libcanberra-dev`` and ``libpython-dev``.
|
||||
if they are not already installed by your distro.
|
||||
|
||||
Install and run from source
|
||||
|
||||
@ -38,6 +38,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
- Fix an out of bounds read causing a crash when selecting text with the mouse
|
||||
in the alternate screen mode (:iss:`1578`)
|
||||
|
||||
- Linux: Use the system "bell" sound for the terminal bell. Adds libcanberra
|
||||
as a new dependency to play the system sound.
|
||||
|
||||
|
||||
0.14.2 [2019-06-09]
|
||||
---------------------
|
||||
|
||||
@ -307,5 +307,8 @@ void fake_scroll(int, bool);
|
||||
void set_special_key_combo(int glfw_key, int mods, bool is_native);
|
||||
void on_key_input(int key, int scancode, int action, int mods, const char*, int);
|
||||
void request_window_attention(id_type, bool);
|
||||
#ifndef __APPLE__
|
||||
void play_canberra_sound(const char *which_sound, const char *event_id);
|
||||
#endif
|
||||
SPRITE_MAP_HANDLE alloc_sprite_map(unsigned int, unsigned int);
|
||||
SPRITE_MAP_HANDLE free_sprite_map(SPRITE_MAP_HANDLE);
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include "data-types.h"
|
||||
#include <dlfcn.h>
|
||||
#include <canberra.h>
|
||||
|
||||
#define FUNC(name, restype, ...) typedef restype (*name##_func)(__VA_ARGS__); static name##_func name = NULL
|
||||
#define LOAD_FUNC(handle, name) {\
|
||||
@ -89,9 +90,25 @@ static PyMethodDef module_methods[] = {
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
static ca_context *canberra_ctx = NULL;
|
||||
|
||||
void
|
||||
play_canberra_sound(const char *which_sound, const char *event_id) {
|
||||
if (canberra_ctx == NULL) ca_context_create(&canberra_ctx);
|
||||
ca_context_play(
|
||||
canberra_ctx, 0,
|
||||
CA_PROP_EVENT_ID, which_sound,
|
||||
CA_PROP_EVENT_DESCRIPTION, event_id,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(void) {
|
||||
if (libsn_handle) dlclose(libsn_handle);
|
||||
libsn_handle = NULL;
|
||||
if (canberra_ctx) ca_context_destroy(canberra_ctx);
|
||||
canberra_ctx = NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@ -819,14 +819,18 @@ get_clipboard_string(PYNOARG) {
|
||||
}
|
||||
|
||||
void
|
||||
ring_audio_bell(OSWindow *w) {
|
||||
ring_audio_bell(OSWindow *w UNUSED) {
|
||||
static double last_bell_at = -1;
|
||||
double now = monotonic();
|
||||
if (now - last_bell_at <= 0.1) return;
|
||||
last_bell_at = now;
|
||||
#ifdef __APPLE__
|
||||
if (w->handle) {
|
||||
glfwWindowBell(w->handle);
|
||||
}
|
||||
#else
|
||||
play_canberra_sound("bell", "kitty bell");
|
||||
#endif
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
|
||||
3
setup.py
3
setup.py
@ -273,6 +273,9 @@ def kitty_env():
|
||||
gl_libs = ['-framework', 'OpenGL'] if is_macos else pkg_config('gl', '--libs')
|
||||
libpng = pkg_config('libpng', '--libs')
|
||||
ans.ldpaths += pylib + font_libs + gl_libs + libpng
|
||||
if not is_macos:
|
||||
cflags.extend(pkg_config('libcanberra', '--cflags-only-I'))
|
||||
ans.ldpaths += pkg_config('libcanberra', '--libs')
|
||||
if is_macos:
|
||||
ans.ldpaths.extend('-framework Cocoa'.split())
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user