From 959fb158282a843cc2785df3b08ffafea02a6efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?=
Date: Mon, 10 Aug 2026 07:30:19 +0200
Subject: [PATCH] xF: play highlight sounds through libcanberra
---
CMakeLists.txt | 19 +++++++++++++++++++
README.adoc | 2 +-
config.h.in | 1 +
xF.c | 30 ++++++++++++++++++++++++++++--
4 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 015ccf9..8b3fe14 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -153,9 +153,23 @@ if (WITH_X11 AND NOT x11_FOUND)
message (FATAL_ERROR "Some X11 libraries were not found")
endif ()
+pkg_check_modules (canberra libcanberra)
+set (canberra_SATISFIED FALSE)
+if (WITH_X11 AND canberra_FOUND)
+ set (canberra_SATISFIED TRUE)
+endif ()
+option (WITH_CANBERRA "Build xF with libcanberra sound support"
+ "${canberra_SATISFIED}")
+if (WITH_CANBERRA AND NOT WITH_X11)
+ message (FATAL_ERROR "libcanberra support requires X11 support")
+elseif (WITH_CANBERRA AND NOT canberra_FOUND)
+ message (FATAL_ERROR "libcanberra not found")
+endif ()
+
# Generate a configuration file
set (HAVE_LUA "${WITH_LUA}")
set (HAVE_X11 "${WITH_X11}")
+set (HAVE_CANBERRA "${WITH_CANBERRA}")
include (GNUInstallDirs)
set (project_config ${PROJECT_BINARY_DIR}/config.h)
@@ -214,6 +228,11 @@ if (WITH_XF)
target_link_directories (xF PRIVATE ${x11_LIBRARY_DIRS})
target_link_libraries (xF PRIVATE ${x11_LIBRARIES})
endif ()
+ if (WITH_CANBERRA)
+ target_include_directories (xF PRIVATE ${canberra_INCLUDE_DIRS})
+ target_link_directories (xF PRIVATE ${canberra_LIBRARY_DIRS})
+ target_link_libraries (xF PRIVATE ${canberra_LIBRARIES})
+ endif ()
add_threads (xF)
endif ()
diff --git a/README.adoc b/README.adoc
index 833987a..2a22b7d 100644
--- a/README.adoc
+++ b/README.adoc
@@ -99,7 +99,7 @@ Build-only dependencies: CMake, pkg-config, awk, liberty (included),
Common runtime dependencies: openssl +
Additionally for 'xC': any curses, lua >= 5.3 (optional), termo (included) +
Additionally for 'xF': ncursesw, libunistring, termo (included),
- x11 + xft + libpng (X11)
+ x11 + xft + libpng (X11), libcanberra (X11, optional)
$ git clone --recursive https://git.janouch.name/p/xK.git
$ mkdir xK/build
diff --git a/config.h.in b/config.h.in
index 85d85ba..95ecddd 100644
--- a/config.h.in
+++ b/config.h.in
@@ -8,6 +8,7 @@
#cmakedefine HAVE_LUA
#cmakedefine HAVE_X11
+#cmakedefine HAVE_CANBERRA
#cmakedefine01 ICONV_ACCEPTS_TRANSLIT
diff --git a/xF.c b/xF.c
index a517983..2a2005c 100644
--- a/xF.c
+++ b/xF.c
@@ -26,6 +26,9 @@
#include "xC-proto.c"
#include