[gnome-shell/message-tray] Kill notification-daemon at startup when running in --replace mode



commit 8fc9d0c8babdfe9c34b90290ac50bc9ddd56959a
Author: Dan Winship <danw gnome org>
Date:   Fri Jan 8 10:29:13 2010 -0500

    Kill notification-daemon at startup when running in --replace mode
    
    https://bugzilla.gnome.org/show_bug.cgi?id=606755

 js/ui/notificationDaemon.js |   46 +++++++++++++++++++++++++++++++-----------
 src/gnome-shell.in          |    5 ++-
 src/shell-global.c          |    2 +-
 3 files changed, 38 insertions(+), 15 deletions(-)
---
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index abcd2ce..0190d66 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -57,18 +57,40 @@ NotificationDaemon.prototype = {
     _init: function() {
         DBus.session.exportObject('/org/freedesktop/Notifications', this);
 
-        let acquiredName = false;
-        DBus.session.acquire_name('org.freedesktop.Notifications', DBus.SINGLE_INSTANCE,
-            function(name) {
-                log("Acquired name " + name);
-                acquiredName = true;
-            },
-            function(name) {
-                if (acquiredName)
-                    log("Lost name " + name);
-                else
-                    log("Could not get name " + name);
-            });
+        this._everAcquiredName = false;
+        DBus.session.acquire_name('org.freedesktop.Notifications',
+                                  // We pass MANY_INSTANCES so that if
+                                  // notification-daemon is running, we'll
+                                  // get queued behind it and then get the
+                                  // name after killing it below
+                                  DBus.MANY_INSTANCES,
+                                  Lang.bind(this, this._acquiredName),
+                                  Lang.bind(this, this._lostName));
+    },
+
+    _acquiredName: function() {
+        this._everAcquiredName = true;
+    },
+
+    _lostName: function() {
+        if (this._everAcquiredName)
+            log('Lost name org.freedesktop.Notifications!');
+        else if (GLib.getenv('GNOME_SHELL_NO_REPLACE'))
+            log('Failed to acquire org.freedesktop.Notifications');
+        else {
+            log('Failed to acquire org.freedesktop.Notifications; trying again');
+
+            // kill the notification-daemon. pkill is more portable
+            // than killall, but on Linux at least it won't match if
+            // you pass more than 15 characters of the process name...
+            // However, if you use the "-f" flag to match the entire
+            // command line, it will work, but we have to be careful
+            // in that case that we don't match "gedit
+            // notification-daemon.c" or whatever...
+            let p = new Shell.Process({ args: ['pkill', '-f',
+                                               '^([^ ]*/)?(notification-daemon|notify-osd)$']});
+            p.run();
+        }
     },
 
     _sourceId: function(id) {
diff --git a/src/gnome-shell.in b/src/gnome-shell.in
old mode 100644
new mode 100755
index 41354ad..254cdee
--- a/src/gnome-shell.in
+++ b/src/gnome-shell.in
@@ -357,8 +357,9 @@ try:
     shell = None
     if options.xephyr:
         xephyr = start_xephyr()
-        # This makes us not grab the org.gnome.Panel name
-        os.environ['GNOME_SHELL_NO_REPLACE_PANEL'] = '1'
+        # This makes us not grab the org.gnome.Panel or
+        # org.freedesktop.Notifications D-Bus names
+        os.environ['GNOME_SHELL_NO_REPLACE'] = '1'
         shell = start_shell()
     else:
         xephyr = None
diff --git a/src/shell-global.c b/src/shell-global.c
index 7fd37c9..3e422b1 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -751,7 +751,7 @@ shell_global_grab_dbus_service (ShellGlobal *global)
    * unless a special environment variable is passed.  The environment
    * variable is used by the gnome-shell (no --replace) launcher in
    * Xephyr */
-  if (!g_getenv ("GNOME_SHELL_NO_REPLACE_PANEL"))
+  if (!g_getenv ("GNOME_SHELL_NO_REPLACE"))
     {
       if (!dbus_g_proxy_call (bus, "RequestName", &error, G_TYPE_STRING,
                               "org.gnome.Panel", G_TYPE_UINT,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]