From c1c95ece1aab10409f856619f3972be3217c069a Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Sun, 6 Mar 2022 15:41:07 +0100 Subject: [PATCH] Allow hardcoding the executable path OpenBSD has neither procfs(5), a sysctl(2) nor any other way to reliably get the absoloute path of the process image. Thus allow passing a fixed path as short-cut which makes tdesktop tdesktop restart as intended when started via `PATH` lookup, i.e. when `argv[0]` contains no path element, which is also what the official .desktop file does (`telegram-desktop -- %u`). --- CMakeLists.txt | 7 +++++++ base/platform/linux/base_file_utilities_linux.cpp | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bf4534..b3fa074 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,6 +294,13 @@ if (DESKTOP_APP_USE_ALLOCATION_TRACER) ) endif() +if (DESKTOP_APP_EXECUTABLE_PATH_OVERRIDE) + target_compile_definitions(lib_base + PRIVATE + DESKTOP_APP_EXECUTABLE_PATH_OVERRIDE="${DESKTOP_APP_EXECUTABLE_PATH_OVERRIDE}" + ) +endif() + #target_precompile_headers(lib_base_crash_report_writer REUSE_FROM lib_base) target_precompile_headers(lib_base_crash_report_writer PRIVATE ${src_loc}/base/base_pch.h) nice_target_sources(lib_base_crash_report_writer ${src_loc} diff --git a/base/platform/linux/base_file_utilities_linux.cpp b/base/platform/linux/base_file_utilities_linux.cpp index 617be01..4bc2ca9 100644 --- a/base/platform/linux/base_file_utilities_linux.cpp +++ b/base/platform/linux/base_file_utilities_linux.cpp @@ -181,6 +181,10 @@ bool ShowInFolder(const QString &filepath) { } QString CurrentExecutablePath(int argc, char *argv[]) { +#ifdef DESKTOP_APP_EXECUTABLE_PATH_OVERRIDE + return QString(DESKTOP_APP_EXECUTABLE_PATH_OVERRIDE); +#endif + if (qEnvironmentVariableIsSet("APPIMAGE")) { const auto appimagePath = qEnvironmentVariable("APPIMAGE"); const auto appimagePathList = appimagePath.split('/');