diff --git a/src/IconRegistry.cpp b/src/IconRegistry.cpp index fae1852..4b812d3 100644 --- a/src/IconRegistry.cpp +++ b/src/IconRegistry.cpp @@ -6,10 +6,10 @@ #include #include #include -#include #include #include +#include #include #include @@ -90,16 +90,50 @@ static auto kde_get_theme() -> std::string const return {}; } +static auto other_get_theme() -> std::string +{ + char const *schema_id { "org.gnome.desktop.interface" }; + char const *key { "icon-theme" }; + + GSettingsSchemaSource *src { g_settings_schema_source_get_default() }; + if (!src) + return {}; + + GSettingsSchema *schema { g_settings_schema_source_lookup( + src, schema_id, TRUE) }; + if (!schema) + return {}; + + GSettings *settings { g_settings_new_full(schema, nullptr, nullptr) }; + g_settings_schema_unref(schema); + if (!settings) + return {}; + + gchar *cstr { g_settings_get_string(settings, key) }; + g_object_unref(settings); + if (!cstr) + return {}; + + std::string theme { cstr }; + g_free(cstr); + return theme; +} + static auto get_current_icon_theme() -> std::optional const { auto de { detect_desktop_environment() }; std::transform(de.begin(), de.end(), de.begin(), ::tolower); - if (de.find("kde") != std::string::npos - || de.find("plasma") != std::string::npos) { + if (0 + && (de.find("kde") != std::string::npos + || de.find("plasma") != std::string::npos)) { if (auto const t = kde_get_theme(); !t.empty()) { return t; } + } else { + if (auto const t = other_get_theme(); !t.empty()) { + return t; + } } return std::nullopt;