From 50a95792a174e1ecb4acc5e1e979046410540dae Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Mon, 28 Sep 2015 11:09:19 -0700 Subject: [PATCH 1/2] Rewrite unity check to look for libunity SOs --- .../linux/notification_presenter_linux.cc | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/brightray/browser/linux/notification_presenter_linux.cc b/brightray/browser/linux/notification_presenter_linux.cc index 557e527047d4..e77075470d11 100644 --- a/brightray/browser/linux/notification_presenter_linux.cc +++ b/brightray/browser/linux/notification_presenter_linux.cc @@ -7,14 +7,17 @@ #include "base/bind.h" #include "base/logging.h" +#include "base/files/file_enumerator.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" #include "content/public/browser/desktop_notification_delegate.h" #include "content/public/common/platform_notification_data.h" #include "common/application_info.h" -#include "dbus/dbus.h" #include "third_party/skia/include/core/SkBitmap.h" +using namespace base; +using namespace std; + namespace brightray { namespace { @@ -23,34 +26,29 @@ static bool unity_has_result = false; static bool unity_result = false; static bool UnityIsRunning() { + FileEnumerator* enumerator = NULL; + if (unity_has_result) { return unity_result; } + + // Look for the presence of libunity as our hint that we're under Ubuntu + FilePath haystack; + string needle("/usr/lib/libunity-"); - struct DBusError err; - struct DBusConnection* bus = NULL; - - dbus_error_init(&err); - - bus = dbus_bus_get(DBUS_BUS_SESSION, &err); - if (dbus_error_is_set(&err)) { - g_debug("Failed to get Session Bus reference"); - unity_result = false; - dbus_error_free(&err); - - goto out; + enumerator = new FileEnumerator(FilePath("/usr/lib"), false, FileEnumerator::FILES); + + while (!((haystack = enumerator->Next()).empty())) { + if (haystack.value().compare(0, needle.length(), needle) == 0) { + unity_result = true; + goto out; + } } - - unity_result = dbus_bus_name_has_owner(bus, "com.canonical.indicator.session", &err); - - if (dbus_error_is_set(&err)) { - unity_result = false; - dbus_error_free(&err); - } - -out: - if (bus) dbus_connection_unref(bus); - + + unity_result = false; + +out: + if (enumerator) delete enumerator; unity_has_result = true; return unity_result; } From 1a8377b198add8a6e005003d2f6d9c76c405ab2e Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 30 Sep 2015 09:14:31 -0700 Subject: [PATCH 2/2] Add environment variable as escape hatch --- brightray/browser/linux/notification_presenter_linux.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/brightray/browser/linux/notification_presenter_linux.cc b/brightray/browser/linux/notification_presenter_linux.cc index e77075470d11..0e92eb5104f8 100644 --- a/brightray/browser/linux/notification_presenter_linux.cc +++ b/brightray/browser/linux/notification_presenter_linux.cc @@ -13,6 +13,7 @@ #include "content/public/browser/desktop_notification_delegate.h" #include "content/public/common/platform_notification_data.h" #include "common/application_info.h" +#include #include "third_party/skia/include/core/SkBitmap.h" using namespace base; @@ -31,6 +32,11 @@ static bool UnityIsRunning() { if (unity_has_result) { return unity_result; } + + if (getenv("ELECTRON_USE_UBUNTU_NOTIFIER")) { + unity_result = true; + goto out; + } // Look for the presence of libunity as our hint that we're under Ubuntu FilePath haystack;