diff --git a/CHANGELOG.md b/CHANGELOG.md index e4e1d05b5..fc5e69485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Features: * Adds Ubuntu Kylin and Ubuntu Unity flavor detection (OS, Linux) * Adds NebiDE support (WMTheme, Linux) * Adds package counting for `cards` on NuTyX (#2287, Packages, Linux) +* Adds support for Enlightenment desktop environment (#2165, WM, Linux) Bugfixes: * Improves DisplayServer compatibility on Linux by handling newer `kde-output-device-v2` protocol updates (DisplayServer, Linux) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2c84cd5f..53de960e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ cmake_dependent_option(ENABLE_DRM "Enable libdrm" ON "LINUX OR FreeBSD OR OpenBS cmake_dependent_option(ENABLE_DRM_AMDGPU "Enable libdrm_amdgpu" ON "LINUX OR FreeBSD OR GNU" OFF) cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU" OFF) cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU" OFF) +cmake_dependent_option(ENABLE_EET "Enable eet" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR GNU" OFF) cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR FreeBSD OR OpenBSD OR NetBSD OR ANDROID OR SunOS OR Haiku OR GNU" OFF) cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR FreeBSD OR APPLE OR OpenBSD OR NetBSD OR SunOS OR GNU" OFF) cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX OR GNU" OFF) @@ -1614,6 +1615,10 @@ ff_lib_enable(DCONF "dconf" "DConf" ) +ff_lib_enable(EET + "eet" + "Eet" +) ff_lib_enable(DBUS "dbus-1" "DBus" diff --git a/src/common/impl/init.c b/src/common/impl/init.c index 123a9dd99..1d3fa8ccc 100644 --- a/src/common/impl/init.c +++ b/src/common/impl/init.c @@ -203,6 +203,9 @@ void ffListFeatures(void) { #if FF_HAVE_DCONF "dconf\n" #endif +#if FF_HAVE_EET + "eet\n" +#endif #if FF_HAVE_DBUS "dbus\n" #endif diff --git a/src/common/impl/settings.c b/src/common/impl/settings.c index a44a66fd3..2c3b6d02d 100644 --- a/src/common/impl/settings.c +++ b/src/common/impl/settings.c @@ -485,3 +485,127 @@ bool ffSettingsGetFreeBSDKenv(const char* propName, FFstrbuf* result) { return true; } #endif + +#ifdef FF_HAVE_EET + #if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Weverything" + #elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wall" + #pragma GCC diagnostic ignored "-Wextra" + #pragma GCC diagnostic ignored "-Wpedantic" + #pragma GCC diagnostic ignored "-Wunknown-pragmas" + #endif + #include + #if defined(__clang__) + #pragma clang diagnostic pop + #elif defined(__GNUC__) + #pragma GCC diagnostic pop + #endif + +typedef struct E_Font_Default { + char* text_class; + char* font; + int size; +} E_Font_Default; + +typedef struct E_Config { + char* theme_default_border_style; + char* icon_theme; + int use_e_cursor; + int cursor_size; + char* desktop_default_background; + Eina_List* font_defaults; +} E_Config; // Must be the same name as the top level struct in e.cfg + + #define FF_EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(clas, type) \ + (ffeet_eina_file_data_descriptor_class_set(clas, sizeof(*(clas)), #type, sizeof(type))) + #define FF_EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, member, type) \ + do { \ + struct_type ___ett; \ + ffeet_data_descriptor_element_add(edd, #member, type, EET_G_UNKNOWN, (char*) (&(___ett.member)) - (char*) (&(___ett)), 0, /* 0, */ NULL, NULL); \ + } while (0) + #define FF_EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, member, subtype) \ + do { \ + struct_type ___ett; \ + ffeet_data_descriptor_element_add(edd, #member, EET_T_UNKNOW, EET_G_LIST, (char*) (&(___ett.member)) - (char*) (&(___ett)), 0, /* 0, */ NULL, subtype); \ + } while (0) + +bool ffSettingsGetEnlightenmentProperty(ffEnlightenmentSettings* result) { + FF_LIBRARY_LOAD(libeet, false, "libeet" FF_LIBRARY_EXTENSION, 1); + FF_LIBRARY_LOAD_SYMBOL(libeet, eet_init, false); + FF_LIBRARY_LOAD_SYMBOL(libeet, eet_open, false); + FF_LIBRARY_LOAD_SYMBOL(libeet, eet_data_descriptor_file_new, false); + FF_LIBRARY_LOAD_SYMBOL(libeet, eet_data_read, false); + FF_LIBRARY_LOAD_SYMBOL(libeet, eet_close, false); + FF_LIBRARY_LOAD_SYMBOL(libeet, eet_data_descriptor_free, false); + FF_LIBRARY_LOAD_SYMBOL(libeet, eet_eina_file_data_descriptor_class_set, false); + FF_LIBRARY_LOAD_SYMBOL(libeet, eet_data_descriptor_element_add, false); + + if (ffeet_init() == 0) { + return false; + } + + FF_STRBUF_AUTO_DESTROY fileName = ffStrbufCreateCopy(&instance.state.platform.homeDir); + ffStrbufAppendS(&fileName, ".e/e/config/standard/e.cfg"); + + Eet_File* ef = ffeet_open(fileName.chars, EET_FILE_MODE_READ); + if (!ef) { + return false; + } + + Eet_Data_Descriptor_Class fontDdc; + FF_EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&fontDdc, E_Font_Default); + Eet_Data_Descriptor* fontDdd = ffeet_data_descriptor_file_new(&fontDdc); + if (!fontDdd) { + ffeet_close(ef); + return false; + } + FF_EET_DATA_DESCRIPTOR_ADD_BASIC(fontDdd, E_Font_Default, text_class, EET_T_STRING); + FF_EET_DATA_DESCRIPTOR_ADD_BASIC(fontDdd, E_Font_Default, font, EET_T_STRING); + FF_EET_DATA_DESCRIPTOR_ADD_BASIC(fontDdd, E_Font_Default, size, EET_T_INT); + + Eet_Data_Descriptor_Class eddc; + FF_EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, E_Config); + Eet_Data_Descriptor* edd = ffeet_data_descriptor_file_new(&eddc); + if (!edd) { + ffeet_data_descriptor_free(fontDdd); + ffeet_close(ef); + return false; + } + + FF_EET_DATA_DESCRIPTOR_ADD_BASIC(edd, E_Config, theme_default_border_style, EET_T_STRING); + FF_EET_DATA_DESCRIPTOR_ADD_BASIC(edd, E_Config, icon_theme, EET_T_STRING); + FF_EET_DATA_DESCRIPTOR_ADD_BASIC(edd, E_Config, use_e_cursor, EET_T_INT); + FF_EET_DATA_DESCRIPTOR_ADD_BASIC(edd, E_Config, cursor_size, EET_T_INT); + FF_EET_DATA_DESCRIPTOR_ADD_BASIC(edd, E_Config, desktop_default_background, EET_T_STRING); + FF_EET_DATA_DESCRIPTOR_ADD_LIST(edd, E_Config, font_defaults, fontDdd); + + E_Config* parsed = ffeet_data_read(ef, edd, "config"); + + if (parsed) { + // TODO: find a better method to get the main theme name + result->theme = parsed->theme_default_border_style; + result->icon_theme = parsed->icon_theme; + result->use_e_cursor = !!parsed->use_e_cursor; + result->cursor_size = parsed->cursor_size; + result->desktop_default_background = parsed->desktop_default_background; + + E_Font_Default* firstFont = eina_list_data_get(parsed->font_defaults); + if (firstFont) { + result->font = firstFont->font; + } + } + + ffeet_close(ef); + ffeet_data_descriptor_free(edd); + ffeet_data_descriptor_free(fontDdd); + + return !!parsed; +} +#else +bool ffSettingsGetEnlightenmentProperty(FF_A_UNUSED ffEnlightenmentSettings* result) { + return false; +} +#endif diff --git a/src/common/settings.h b/src/common/settings.h index 02658670e..f2143cf46 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -30,6 +30,16 @@ FFvariant ffSettingsGetXFConfFirstMatch(const char* channelName, const char* pro int ffSettingsGetSQLite3Int(const char* dbPath, const char* query); bool ffSettingsGetSQLite3String(const char* dbPath, const char* query, FFstrbuf* result); +typedef struct { + char* theme; + char* icon_theme; + bool use_e_cursor; + int cursor_size; + char* desktop_default_background; + char* font; +} ffEnlightenmentSettings; +bool ffSettingsGetEnlightenmentProperty(ffEnlightenmentSettings* result); + #ifdef __ANDROID__ bool ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result); #elif defined(__FreeBSD__) diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index 9dd41ec23..b33f2c84b 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -42,6 +42,7 @@ #define FF_WM_PRETTY_FVWM "fvwm" #define FF_WM_PRETTY_CTWM "ctwm" #define FF_WM_PRETTY_RATPOISON "ratpoison" +#define FF_WM_PRETTY_ENLIGHTENMENT "Enlightenment" #define FF_WM_PROTOCOL_TTY "TTY" #define FF_WM_PROTOCOL_X11 "X11" diff --git a/src/detection/gtk_qt/gtk.c b/src/detection/gtk_qt/gtk.c index 41da10e70..e2af5ef6d 100644 --- a/src/detection/gtk_qt/gtk.c +++ b/src/detection/gtk_qt/gtk.c @@ -95,6 +95,17 @@ static void detectGTKFromSettings(FFGTKResult* result) { cursorTheme = ffSettingsGetGnome("/org/gnome/desktop/interface/cursor-theme", "org.gnome.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue; cursorSize = ffSettingsGetGnome("/org/gnome/desktop/interface/cursor-size", "org.gnome.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue; wallpaper = ffSettingsGetGnome("/org/gnome/desktop/background/picture-uri", "org.gnome.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue; + } else if ( + ffStrbufIgnCaseEqualS(&wmde->dePrettyName, FF_DE_PRETTY_ENLIGHTENMENT)) { + ffEnlightenmentSettings settings; + if (ffSettingsGetEnlightenmentProperty(&settings)) { + themeName = settings.theme; + iconsName = settings.icon_theme; + fontName = settings.font; + cursorTheme = settings.use_e_cursor ? "Enlightenment" : "Application"; + cursorSize = settings.cursor_size; + wallpaper = settings.desktop_default_background; + } } applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize, wallpaper); diff --git a/src/detection/wmtheme/wmtheme_linux.c b/src/detection/wmtheme/wmtheme_linux.c index adc3cd5aa..685ba5f5e 100644 --- a/src/detection/wmtheme/wmtheme_linux.c +++ b/src/detection/wmtheme/wmtheme_linux.c @@ -220,6 +220,10 @@ bool ffDetectWmTheme(FFstrbuf* themeOrError) { return detectOpenbox(&wm->dePrettyName, themeOrError); } + if (ffStrbufIgnCaseEqualS(&wm->wmPrettyName, FF_WM_PRETTY_ENLIGHTENMENT)) { + return detectGTKThemeAsWMTheme(themeOrError); + } + ffStrbufAppendS(themeOrError, "Unknown WM: "); ffStrbufAppend(themeOrError, &wm->wmPrettyName); return false;