From a84a7e6a5c3fe16b5e1d1a9824422638aca2f975 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 13 Jul 2022 17:24:34 +0200 Subject: [PATCH] Fixed: Getting selfpath on macos (fix for finding theme folder) --- src/btop.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/btop.cpp b/src/btop.cpp index b114753..484a0df 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -34,6 +34,8 @@ tab-size = 4 #include #ifdef __APPLE__ #include + #include + #include #endif #include @@ -699,10 +701,17 @@ int main(int argc, char **argv) { } } //? Try to find global btop theme path relative to binary path -#if defined(__linux__) +#ifdef __linux__ { std::error_code ec; Global::self_path = fs::read_symlink("/proc/self/exe", ec).remove_filename(); } +#elif __APPLE__ + { + char buf [PATH_MAX]; + uint32_t bufsize = PATH_MAX; + if(!_NSGetExecutablePath(buf, &bufsize)) + Global::self_path = fs::path(buf).remove_filename(); + } #endif if (std::error_code ec; not Global::self_path.empty()) { Theme::theme_dir = fs::canonical(Global::self_path / "../share/btop/themes", ec);