1
0
mirror of synced 2024-11-24 07:40:17 +01:00

fix: Fix theme detection on Linux (#1512)

This commit is contained in:
iTrooz 2024-01-25 20:46:12 +01:00 committed by GitHub
parent 82b56613e9
commit e61ee528ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,7 +73,8 @@ namespace hex {
std::array<char, 128> 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