From 117f61a906a13e5220d3e368787bf1392ab58144 Mon Sep 17 00:00:00 2001
From: Clemens Lang <cal@macports.org>
Date: Tue, 24 Sep 2024 13:31:43 +0200
Subject: [PATCH] Added: Search for themes relative to binary

When installed in non-default paths (i.e., not /usr or /usr/local),
bpytop cannot find its themes in $prefix/share/bpytop/themes. Start from
the path of the executable to handle non-default values of $prefix.

Upstream-Status: Submitted [https://github.com/aristocratos/bpytop/pull/422]
---
 bpytop.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bpytop.py b/bpytop.py
index eff3704..9ffa394 100755
--- ./bpytop.py
+++ ./bpytop.py
@@ -256,7 +256,12 @@ if os.path.isdir(f'{os.path.dirname(__file__)}/bpytop-themes'):
 elif os.path.isdir(f'{os.path.dirname(__file__)}/themes'):
 	THEME_DIR = f'{os.path.dirname(__file__)}/themes'
 else:
-	for td in ["/usr/local/", "/usr/", "/snap/bpytop/current/usr/"]:
+	for td in [
+            os.path.dirname(os.path.dirname(__file__)).rstrip("/") + "/",
+            "/usr/local/",
+            "/usr/",
+            "/snap/bpytop/current/usr/"
+        ]:
 		if os.path.isdir(f'{td}share/bpytop/themes'):
 			THEME_DIR = f'{td}share/bpytop/themes'
 			break
-- 
2.46.1

