Commit 4d6ee3f5 authored by Benjamin Berg's avatar Benjamin Berg

main: Enable systemd usage

This flips the switch and enables systemd usage in gnome-session.
parent e6a94c31
......@@ -49,6 +49,8 @@
#define GSM_DBUS_NAME "org.gnome.SessionManager"
static gboolean systemd_service = FALSE;
static gboolean use_systemd = USE_SYSTEMD_SESSION;
static gboolean failsafe = FALSE;
static gboolean show_version = FALSE;
static gboolean debug = FALSE;
......@@ -139,7 +141,7 @@ create_manager (void)
GsmStore *client_store;
client_store = gsm_store_new ();
manager = gsm_manager_new (client_store, failsafe, FALSE);
manager = gsm_manager_new (client_store, failsafe, systemd_service);
g_object_unref (client_store);
g_unix_signal_add (SIGTERM, term_or_int_signal_cb, manager);
......@@ -384,6 +386,11 @@ main (int argc, char **argv)
guint name_owner_id;
GOptionContext *options;
static GOptionEntry entries[] = {
#ifdef ENABLE_SYSTEMD_SESSION
{ "systemd-service", 0, 0, G_OPTION_ARG_NONE, &systemd_service, N_("Running as systemd service"), NULL },
{ "systemd", 0, 0, G_OPTION_ARG_NONE, &use_systemd, N_("Use systemd session management"), NULL },
#endif
{ "builtin", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &use_systemd, N_("Use builtin session management (rather than the systemd based one)"), NULL },
{ "autostart", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &override_autostart_dirs, N_("Override standard autostart directories"), N_("AUTOSTART_DIR") },
{ "session", 0, 0, G_OPTION_ARG_STRING, &opt_session_name, N_("Session to use"), N_("SESSION_NAME") },
{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
......@@ -452,7 +459,12 @@ main (int argc, char **argv)
gdm_log_init ();
gdm_log_set_debug (debug);
if (disable_acceleration_check) {
if (systemd_service) {
/* XXX: This is an optimization, but we actually need to do
* it right now as the DISPLAY environment might leak
* into the new session from an old run. */
g_debug ("hardware acceleration already done if needed");
} else if (disable_acceleration_check) {
g_debug ("hardware acceleration check is disabled");
} else {
/* Check GL, if it doesn't work out then force software fallback */
......@@ -511,10 +523,39 @@ main (int argc, char **argv)
gsm_util_export_activation_environment (NULL);
session_name = opt_session_name;
#ifdef HAVE_SYSTEMD
gsm_util_export_user_environment (NULL);
#endif
#ifdef ENABLE_SYSTEMD_SESSION
if (use_systemd && !systemd_service) {
g_autoptr(GError) error = NULL;
g_autofree gchar *gnome_session_target;
const gchar *session_type;
session_type = g_getenv ("XDG_SESSION_TYPE");
/* We really need to resolve the session name at this point,
* which requires talking to GSettings internally. */
if (IS_STRING_EMPTY (session_name)) {
session_name = _gsm_manager_get_default_session (NULL);
}
/* We don't escape the name (i.e. we leave any '-' intact). */
gnome_session_target = g_strdup_printf ("gnome-session-%s@%s.target", session_type, session_name);
if (gsm_util_start_systemd_unit (gnome_session_target, "fail", &error)) {
/* We started the unit, open fifo and sleep forever. */
systemd_leader_run ();
exit(0);
}
/* We could not start the unit, fall back. */
g_warning ("Falling back to non-systemd startup procedure due to error: %s", error->message);
}
#endif /* ENABLE_SYSTEMD_SESSION */
{
gchar *ibus_path;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment