From e61ee528ff43fa7dcd3fa3d043c1f74757a3002b Mon Sep 17 00:00:00 2001 From: iTrooz Date: Thu, 25 Jan 2024 20:46:12 +0100 Subject: [PATCH] fix: Fix theme detection on Linux (#1512) --- main/gui/source/window/linux_window.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/gui/source/window/linux_window.cpp b/main/gui/source/window/linux_window.cpp index f27535532..4518f2913 100644 --- a/main/gui/source/window/linux_window.cpp +++ b/main/gui/source/window/linux_window.cpp @@ -73,7 +73,8 @@ namespace hex { std::array buffer = { 0 }; std::string result; - // Ask dbus for the current theme. 0 for Light, 1 for Dark + // Ask dbus for the current theme. 1 for Dark, 2 for Light, 0 for default (Dark for ImHex) + // https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Settings.html 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; @@ -83,7 +84,7 @@ namespace hex { auto exitCode = WEXITSTATUS(pclose(pipe)); if (exitCode != 0) return; - RequestChangeTheme::post(hex::containsIgnoreCase(result, "uint32 1") ? "Light" : "Dark"); + RequestChangeTheme::post(hex::containsIgnoreCase(result, "uint32 2") ? "Light" : "Dark"); }); // Register file drop callback