diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 277e11aa13..dd0e5966e2 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -382,12 +382,6 @@ QString GetIconName() { std::optional IsDarkMode() { #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION [[maybe_unused]] static const auto Inited = [] { - static const auto Setter = [] { - crl::on_main([] { - Core::App().settings().setSystemDarkMode(IsDarkMode()); - }); - }; - using XDPSettingWatcher = base::Platform::XDP::SettingWatcher; static const XDPSettingWatcher Watcher( [=]( @@ -396,7 +390,14 @@ std::optional IsDarkMode() { const Glib::VariantBase &value) { if (group == "org.freedesktop.appearance" && key == "color-scheme") { - Setter(); + try { + const auto ivalue = base::Platform::GlibVariantCast(value); + + crl::on_main([=] { + Core::App().settings().setSystemDarkMode(ivalue == 1); + }); + } catch (...) { + } } }); @@ -410,10 +411,7 @@ std::optional IsDarkMode() { if (result.has_value()) { const auto value = base::Platform::GlibVariantCast(*result); - if (value == 1) { - return true; - } - return false; + return value == 1; } } catch (...) { }