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:
Kovid Goyal
2019-07-03 22:06:47 +05:30
parent 2e8188e89d
commit 2cfd55f3ce
6 changed files with 33 additions and 2 deletions

View File

@@ -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