Skip to content


manager: restart user bus if last graphical session
Browse files Browse the repository at this point in the history
There are desktop services (such as goa-daemon, e-d-s, etc)
that don't open the display, but rely on dbus-daemon to scope
the session. These days dbus-daemon is a user bus, not a sesssion,
bus which leaves these services alive after log out.

This commit checks to see if we're the last desktop session for the
user at log out time, and if so, restarts the dbus daemon. This
will lead to existing clients getting booted and die, but allow user
bus clients that want to outlive a session to stick around if they so

Longer term, clients should stop relying on the session bus to define
their lifetime.
Adapted from
  • Loading branch information
vkareh committed Feb 4, 2019
1 parent 37d538e commit 9c748b1
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions mate-session/gsm-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,51 @@ _client_stop (const char *id,
return FALSE;

static void
maybe_restart_user_bus (GsmManager *manager)
GsmSystemd *systemd;
GsmManagerPrivate *priv;
GDBusConnection *connection;

g_autoptr(GVariant) reply = NULL;
g_autoptr(GError) error = NULL;

priv = gsm_manager_get_instance_private (manager);
if (priv->dbus_disconnected)

systemd = gsm_get_systemd ();

if (!gsm_systemd_is_last_session_for_user (systemd))

connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);

if (error != NULL) {
g_debug ("GsmManager: failed to connect to session bus: %s", error->message);

reply = g_dbus_connection_call_sync (connection,
g_variant_new ("(ss)", "dbus.service", "replace"),

if (error != NULL) {
g_debug ("GsmManager: reloading user bus failed: %s", error->message);

static void
do_phase_exit (GsmManager *manager)
Expand All @@ -901,6 +946,10 @@ do_phase_exit (GsmManager *manager)

maybe_restart_user_bus (manager);

end_phase (manager);

Expand Down

0 comments on commit 9c748b1

Please sign in to comment.