summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2025-01-20 11:07:47 +0100
committerRoland Reichwein <mail@reichwein.it>2025-01-20 11:07:47 +0100
commit78ace79b86aeba3575b2abe2ba617798f6d8da85 (patch)
tree53343326b96229d4930f2c6650b52d930f03f4b6
parentb527be73791648a6fa424a3b654d84374bb0bd86 (diff)
Install click file
-rw-r--r--Makefile2
-rw-r--r--config.cpp16
2 files changed, 17 insertions, 1 deletions
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