From ee11a06c2625b9753bc074df78bf1968c9e04191 Mon Sep 17 00:00:00 2001
From: begasus <begasus@gmail.com>
Date: Fri, 8 Oct 2021 16:16:32 +0000
Subject: Fix finding catalogs when launched from Deskbar


diff --git a/src/ui/main.cpp b/src/ui/main.cpp
index c913284..7724c07 100644
--- a/src/ui/main.cpp
+++ b/src/ui/main.cpp
@@ -46,6 +46,11 @@
 #include "grlib.h"
 #include "i18n.h"
 
+#ifdef __HAIKU__
+#include <libgen.h>
+#include <unistd.h>
+#endif
+
 /* Command line variables */
 int printspeed;
 int delaytime = 0;
@@ -557,6 +562,11 @@ static void ui_registermenus_i18n(void)
 
 int main(int argc, char *argv[])
 {
+	char *binpath = realpath(argv[0], NULL);
+	if (binpath != NULL) {
+		chdir(dirname(binpath));
+		free(binpath);
+	}
 #ifdef _WIN32
     // On Windows, attach to parent console to allow command-line output
     if (AttachConsole(ATTACH_PARENT_PROCESS)) {
@@ -565,6 +575,7 @@ int main(int argc, char *argv[])
     }
 #endif
 
+
     QCoreApplication::setApplicationName("XaoS");
     QCoreApplication::setApplicationVersion(XaoS_VERSION);
     QCoreApplication::setOrganizationName("XaoS Project");
-- 
2.30.2

