From 19f3da556c44d2a02d15045fef47af28d1307613 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 4 Dec 2023 23:35:48 +0100 Subject: [PATCH] fix: Native theme detection on Linux not working properly --- main/gui/source/window/linux_window.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main/gui/source/window/linux_window.cpp b/main/gui/source/window/linux_window.cpp index 0a072ab58..bf02328b5 100644 --- a/main/gui/source/window/linux_window.cpp +++ b/main/gui/source/window/linux_window.cpp @@ -73,9 +73,8 @@ namespace hex { std::array buffer = { 0 }; std::string result; - // Ask GNOME for the current theme - // TODO: In the future maybe support more DEs instead of just GNOME - FILE *pipe = popen("gsettings get org.gnome.desktop.interface gtk-theme 2>&1", "r"); + // Ask dbus for the current theme. 0 for Light, 1 for Dark + FILE *pipe = popen("dbus-send --session --print-reply --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:'org.freedesktop.appearance' string:'color-scheme' 2>&1", "r"); if (pipe == nullptr) return; while (fgets(buffer.data(), buffer.size(), pipe) != nullptr) @@ -84,7 +83,7 @@ namespace hex { auto exitCode = WEXITSTATUS(pclose(pipe)); if (exitCode != 0) return; - EventManager::post(hex::containsIgnoreCase(result, "light") ? "Light" : "Dark"); + EventManager::post(hex::containsIgnoreCase(result, "uint32 1") ? "Light" : "Dark"); }); if (themeFollowSystem)