Skip to content

Commit

Permalink
fix: Fix theme detection on Linux (WerWolv#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
iTrooz authored Jan 25, 2024
1 parent 82b5661 commit e61ee52
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main/gui/source/window/linux_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit e61ee52

Please sign in to comment.