summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
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 /config.cpp
parentb527be73791648a6fa424a3b654d84374bb0bd86 (diff)
Install click file
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp16
1 files changed, 15 insertions, 1 deletions
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