From 78ace79b86aeba3575b2abe2ba617798f6d8da85 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 20 Jan 2025 11:07:47 +0100 Subject: Install click file --- Makefile | 2 ++ config.cpp | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3561227..1d7a760 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,8 @@ $(TARGET): $(OBJS) install: mkdir -p $(DESTDIR)/usr/bin cp $(TARGET) $(DESTDIR)/usr/bin + mkdir -p $(DESTDIR)/usr/lib/click/media + cp media/click.s16le $(DESTDIR)/usr/lib/click/media clean: rm -f $(TARGET) $(OBJS) diff --git a/config.cpp b/config.cpp index d0a7671..d51f6f6 100644 --- a/config.cpp +++ b/config.cpp @@ -19,6 +19,8 @@ std::string config_filename = "click.cfg"; fs::path click_data_filename = "media/click.s16le"; +fs::path libdir = "/usr/lib/click"; + const std::string programname = "click"; Config::Config(int argc, char** argv): @@ -161,7 +163,19 @@ std::string Config::get_argv(int i) const std::filesystem::path Config::get_click_data_filename() const { - return fs::path{m_argv[0]}.parent_path() / click_data_filename; + // 1st try: executable-local media/click.s16le + fs::path result{fs::path{m_argv[0]}.parent_path() / click_data_filename}; + if (fs::exists(result)) { + return result; + } + + // 2nd try: + result = libdir / click_data_filename; + if (fs::exists(result)) { + return result; + } + + throw std::runtime_error("Click file not found"); } std::string Config::get_programname() const -- cgit v1.2.3