Kill notification-daemon at startup when running in --replace mode

https://bugzilla.gnome.org/show_bug.cgi?id=606755
This commit is contained in:
Dan Winship 2010-01-08 10:29:13 -05:00 committed by Marina Zhurakhinskaya
parent 803a204604
commit 8fc9d0c8ba
3 changed files with 38 additions and 15 deletions

View File

@ -57,18 +57,40 @@ NotificationDaemon.prototype = {
_init: function() { _init: function() {
DBus.session.exportObject('/org/freedesktop/Notifications', this); DBus.session.exportObject('/org/freedesktop/Notifications', this);
let acquiredName = false; this._everAcquiredName = false;
DBus.session.acquire_name('org.freedesktop.Notifications', DBus.SINGLE_INSTANCE, DBus.session.acquire_name('org.freedesktop.Notifications',
function(name) { // We pass MANY_INSTANCES so that if
log("Acquired name " + name); // notification-daemon is running, we'll
acquiredName = true; // 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));
}, },
function(name) {
if (acquiredName) _acquiredName: function() {
log("Lost name " + name); this._everAcquiredName = true;
else },
log("Could not get name " + name);
}); _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) { _sourceId: function(id) {

5
src/gnome-shell.in Normal file → Executable file
View File

@ -357,8 +357,9 @@ try:
shell = None shell = None
if options.xephyr: if options.xephyr:
xephyr = start_xephyr() xephyr = start_xephyr()
# This makes us not grab the org.gnome.Panel name # This makes us not grab the org.gnome.Panel or
os.environ['GNOME_SHELL_NO_REPLACE_PANEL'] = '1' # org.freedesktop.Notifications D-Bus names
os.environ['GNOME_SHELL_NO_REPLACE'] = '1'
shell = start_shell() shell = start_shell()
else: else:
xephyr = None xephyr = None

View File

@ -751,7 +751,7 @@ shell_global_grab_dbus_service (ShellGlobal *global)
* unless a special environment variable is passed. The environment * unless a special environment variable is passed. The environment
* variable is used by the gnome-shell (no --replace) launcher in * variable is used by the gnome-shell (no --replace) launcher in
* Xephyr */ * 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, if (!dbus_g_proxy_call (bus, "RequestName", &error, G_TYPE_STRING,
"org.gnome.Panel", G_TYPE_UINT, "org.gnome.Panel", G_TYPE_UINT,