diff --git a/.gitmodules b/.gitmodules index ff41384..91223d5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "subprojects/glaze"] path = subprojects/glaze url = https://github.com/stephenberry/glaze +[submodule "subprojects/dbus_cxx"] + path = subprojects/dbus_cxx + url = https://github.com/dbus-cxx/dbus-cxx diff --git a/meson.build b/meson.build index f16abbb..1301d58 100644 --- a/meson.build +++ b/meson.build @@ -135,7 +135,6 @@ elif host_system == 'linux' dependency('xdmcp'), dependency('wayland-client'), dependency('sigc++-3.0', include_type : 'system'), - dependency('dbus-cxx', include_type : 'system'), ] endif @@ -159,6 +158,14 @@ if not ftxui_dep.found() ) endif +dbus_cxx_dep = dependency('dbus-cxx', include_type : 'system', required : false) + +if not dbus_cxx_dep.found() + cmake = import('cmake') + dbus_cxx_proj = cmake.subproject('dbus_cxx') + dbus_cxx_dep = dbus_cxx_proj.dependency('dbus_cxx', include_type : 'system') +endif + glaze_dep = dependency('glaze', include_type : 'system', required : false) if not glaze_dep.found() @@ -168,7 +175,7 @@ if not glaze_dep.found() endif # Combine all dependencies -deps = common_deps + platform_deps + ftxui_dep + glaze_dep +deps = common_deps + platform_deps + ftxui_dep + dbus_cxx_dep + glaze_dep # ------------------------- # # Link/ObjC Configuration # diff --git a/src/core/system_data.cpp b/src/core/system_data.cpp index 96a1b8d..ed7a920 100644 --- a/src/core/system_data.cpp +++ b/src/core/system_data.cpp @@ -14,7 +14,7 @@ namespace { try { return std::format(std::locale(""), "{:%B %d}", ymd); } catch (const std::runtime_error& e) { - ERROR_LOG("Warning: Could not retrieve or use system locale ({}). Falling back to default C locale.", e.what()); + WARN_LOG("Could not retrieve or use system locale ({}). Falling back to default C locale.", e.what()); return std::format(std::locale::classic(), "{:%B %d}", ymd); } } diff --git a/src/os/linux.cpp b/src/os/linux.cpp index f4113b1..b31efe2 100644 --- a/src/os/linux.cpp +++ b/src/os/linux.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -162,50 +163,14 @@ namespace { if (const usize colon = xdgCurrentDesktop->find(':'); colon != String::npos) return xdgCurrentDesktop->substr(0, colon); + DEBUG_LOG("Found XDG_CURRENT_DESKTOP: {}", *xdgCurrentDesktop); + return *xdgCurrentDesktop; } - if (Result desktopSession = GetEnv("DESKTOP_SESSION")) + if (Result desktopSession = GetEnv("DESKTOP_SESSION")) { + DEBUG_LOG("Found DESKTOP_SESSION: {}", *desktopSession); return *desktopSession; - - return None; - } - - fn DetectFromSessionFiles() -> Option { - // clang-format off - static constexpr Array, 12> DE_PATTERNS = {{ - { "budgie", "Budgie" }, - { "cinnamon", "Cinnamon" }, - { "lxqt", "LXQt" }, - { "mate", "MATE" }, - { "unity", "Unity" }, - { "gnome", "GNOME" }, - { "gnome-wayland", "GNOME" }, - { "gnome-xorg", "GNOME" }, - { "kde", "KDE" }, - { "plasma", "KDE" }, - { "plasmax11", "KDE" }, - { "xfce", "XFCE" }, - }}; - // clang-format on - - static constexpr Array SESSION_PATHS = { "/usr/share/xsessions", "/usr/share/wayland-sessions" }; - - for (const StringView& path : SESSION_PATHS) { - if (!fs::exists(path)) - continue; - - for (const fs::directory_entry& entry : fs::directory_iterator(path)) { - if (!entry.is_regular_file()) - continue; - - String lowercaseStem = entry.path().stem().string(); - std::ranges::transform(lowercaseStem, lowercaseStem.begin(), tolower); - - for (const auto [fst, snd] : DE_PATTERNS) - if (fst == lowercaseStem) - return String(snd); - } } return None; @@ -228,8 +193,10 @@ namespace { const String envVars((std::istreambuf_iterator(cmdline)), std::istreambuf_iterator()); for (const auto& [process, deName] : processChecks) - if (envVars.contains(process)) + if (envVars.contains(process)) { + DEBUG_LOG("Found from process check: {}", deName); return String(deName); + } return None; } @@ -374,8 +341,11 @@ fn os::GetWindowManager() -> String { if (const Result xdgSessionType = GetEnv("XDG_SESSION_TYPE"); waylandDisplay || (xdgSessionType && xdgSessionType->contains("wayland"sv))) { String compositor = GetWaylandCompositor(); - if (!compositor.empty()) + + if (!compositor.empty()) { + DEBUG_LOG("Found compositor: {}", compositor); return compositor; + } if (const Result xdgCurrentDesktop = GetEnv("XDG_CURRENT_DESKTOP")) { std::ranges::transform(compositor, compositor.begin(), tolower); @@ -394,9 +364,6 @@ fn os::GetDesktopEnvironment() -> Option { if (Option desktopEnvironment = DetectFromEnvVars()) return desktopEnvironment; - if (Option desktopEnvironment = DetectFromSessionFiles()) - return desktopEnvironment; - return DetectFromProcesses(); } diff --git a/src/util/types.h b/src/util/types.h index 1e928b8..d9fbd36 100644 --- a/src/util/types.h +++ b/src/util/types.h @@ -1,6 +1,7 @@ #pragma once #include // std::array alias (Array) +#include // std::float_t, std::double_t (f32/f64) #include // std::getenv, std::free #include // std::expected alias (Result) #include // std::map alias (Map) diff --git a/subprojects/dbus_cxx b/subprojects/dbus_cxx new file mode 160000 index 0000000..0285006 --- /dev/null +++ b/subprojects/dbus_cxx @@ -0,0 +1 @@ +Subproject commit 0285006ac71ba6b16d82a69d3927a85e1c104e4e diff --git a/subprojects/glaze b/subprojects/glaze index bad0345..bcf97a0 160000 --- a/subprojects/glaze +++ b/subprojects/glaze @@ -1 +1 @@ -Subproject commit bad0345d6358a649d5f72e90ada2be75d04b75cd +Subproject commit bcf97a05c81ee249cff8a064a222480cadc25429 diff --git a/subprojects/sqlite3.wrap b/subprojects/sqlite3.wrap new file mode 100644 index 0000000..8fe9601 --- /dev/null +++ b/subprojects/sqlite3.wrap @@ -0,0 +1,2 @@ +[wrap-redirect] +filename = SQLiteCpp-3.3.2/subprojects/sqlite3.wrap