Commit e5ccfa69 authored by Benjamin Berg's avatar Benjamin Berg Committed by Ray Strode

autostart-app: Place launched applications into a systemd scope

Try to place launched applications into a systemd scope. This will only
have an effect on systemd managed sessions, where it will e.g. protect
gnome-session from OOM actions to a child resulting in a service
shutdown.
parent c5346360
...@@ -28,6 +28,11 @@ ...@@ -28,6 +28,11 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <gio/gdesktopappinfo.h> #include <gio/gdesktopappinfo.h>
#ifdef HAVE_GNOME_SYSTEMD
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-systemd.h>
#endif
#ifdef HAVE_SYSTEMD #ifdef HAVE_SYSTEMD
#ifdef ENABLE_SYSTEMD_JOURNAL #ifdef ENABLE_SYSTEMD_JOURNAL
#include <systemd/sd-journal.h> #include <systemd/sd-journal.h>
...@@ -960,6 +965,15 @@ app_launched (GAppLaunchContext *ctx, ...@@ -960,6 +965,15 @@ app_launched (GAppLaunchContext *ctx,
g_variant_lookup (platform_data, "startup-notification-id", "s", &sn_id); g_variant_lookup (platform_data, "startup-notification-id", "s", &sn_id);
app->priv->pid = pid; app->priv->pid = pid;
app->priv->startup_id = sn_id; app->priv->startup_id = sn_id;
#ifdef HAVE_GNOME_SYSTEMD
/* We are not interested in the result. */
gnome_start_systemd_scope (app->priv->desktop_id,
pid,
NULL,
NULL,
NULL, NULL, NULL);
#endif
} }
#ifdef ENABLE_SYSTEMD_JOURNAL #ifdef ENABLE_SYSTEMD_JOURNAL
......
...@@ -99,11 +99,12 @@ xtrans_dep = dependency('xtrans') ...@@ -99,11 +99,12 @@ xtrans_dep = dependency('xtrans')
ice_dep = dependency('ice') ice_dep = dependency('ice')
sm_dep = dependency('sm') sm_dep = dependency('sm')
x11_dep = dependency('x11') x11_dep = dependency('x11')
gnome_desktop_dep = dependency('gnome-desktop-3.0', version: '>= 3.34.2')
session_deps = [ session_deps = [
gio_dep, gio_dep,
glib_dep, glib_dep,
dependency('gnome-desktop-3.0', version: '>= 3.18.0'), gnome_desktop_dep,
dependency('json-glib-1.0', version: '>= 0.10') dependency('json-glib-1.0', version: '>= 0.10')
] ]
...@@ -171,6 +172,8 @@ config_h.set('ENABLE_SYSTEMD_SESSION', enable_systemd_session) ...@@ -171,6 +172,8 @@ config_h.set('ENABLE_SYSTEMD_SESSION', enable_systemd_session)
config_h.set('ENABLE_SYSTEMD_JOURNAL', enable_systemd_journal) config_h.set('ENABLE_SYSTEMD_JOURNAL', enable_systemd_journal)
config_h.set('HAVE_CONSOLEKIT', enable_consolekit) config_h.set('HAVE_CONSOLEKIT', enable_consolekit)
config_h.set10('USE_SYSTEMD_SESSION', use_systemd_session) config_h.set10('USE_SYSTEMD_SESSION', use_systemd_session)
# Added in gnome-desktop 3.34.2/3.35.2
config_h.set('HAVE_GNOME_SYSTEMD', cc.has_header('libgnome-desktop/gnome-systemd.h', dependencies: gnome_desktop_dep))
configure_file( configure_file(
output: 'config.h', output: 'config.h',
......
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