Gnome moment

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-10-15 03:41:02 +03:00
parent 06418b4cf4
commit 86ecd128f8

View File

@@ -6,10 +6,10 @@
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <print>
#include <ranges>
#include <stdexcept>
#include <gio/gio.h>
#include <lunasvg.h>
#include <mini/ini.h>
@@ -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<std::string> 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;