[gnome-settings-daemon/benzea/spawn-in-scope: 2/2] media-keys: Place spawned processes into a systemd scope
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/benzea/spawn-in-scope: 2/2] media-keys: Place spawned processes into a systemd scope
- Date: Thu, 12 Dec 2019 10:38:02 +0000 (UTC)
commit bd102b0ffb4afd8611eefcaa246092a0949dbc25
Author: Benjamin Berg <bberg redhat com>
Date: Tue Nov 26 18:20:16 2019 +0100
media-keys: Place spawned processes into a systemd scope
This means we isolate the processes from the media-keys scope itself.
For this to work, we need at least libgnome-desktop 3.34.2.1 as the API
was added in that release.
meson.build | 2 +-
plugins/media-keys/gsd-media-keys-manager.c | 35 ++++++++++++++++++++++++++++-
plugins/media-keys/meson.build | 1 +
3 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/meson.build b/meson.build
index 0c65f381..0234cf1d 100644
--- a/meson.build
+++ b/meson.build
@@ -87,7 +87,7 @@ colord_dep = dependency('colord', version: '>= 1.3.5')
geocode_glib_dep = dependency('geocode-glib-1.0', version: '>= 3.10.0')
gio_dep = dependency('gio-2.0', version: '>= 2.53.0')
gio_unix_dep = dependency('gio-unix-2.0')
-gnome_desktop_dep = dependency('gnome-desktop-3.0', version: '>= 3.11.1')
+gnome_desktop_dep = dependency('gnome-desktop-3.0', version: '>= 3.34.2')
gsettings_desktop_dep = dependency('gsettings-desktop-schemas', version: '>= 3.33.0')
gtk_dep = dependency('gtk+-3.0', version: '>= 3.15.3')
gtk_x11_dep = dependency('gtk+-x11-3.0')
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index a7155d2f..f4ab76f5 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -41,6 +41,8 @@
#include <libupower-glib/upower.h>
#include <gdesktop-enums.h>
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <libgnome-desktop/gnome-systemd.h>
#if HAVE_GUDEV
#include <gudev/gudev.h>
@@ -264,7 +266,6 @@ G_DEFINE_TYPE_WITH_PRIVATE (GsdMediaKeysManager, gsd_media_keys_manager, G_TYPE_
static gpointer manager_object = NULL;
-
static void
media_key_unref (MediaKey *key)
{
@@ -996,6 +997,32 @@ init_kbd (GsdMediaKeysManager *manager)
gnome_settings_profile_end (NULL);
}
+static void
+app_launched_cb (GAppLaunchContext *context,
+ GAppInfo *info,
+ GVariant *platform_data,
+ gpointer user_data)
+{
+ GsdMediaKeysManager *manager = GSD_MEDIA_KEYS_MANAGER (user_data);
+ GsdMediaKeysManagerPrivate *priv = GSD_MEDIA_KEYS_MANAGER_GET_PRIVATE (manager);
+ gint32 pid;
+ const gchar *app_name;
+
+ if (!g_variant_lookup (platform_data, "pid", "i", &pid))
+ return;
+
+ app_name = g_app_info_get_id (info);
+ if (app_name == NULL)
+ app_name = g_app_info_get_executable (info);
+
+ /* Start async request; we don't care about the result */
+ gnome_start_systemd_scope (app_name,
+ pid,
+ NULL,
+ priv->connection,
+ NULL, NULL, NULL);
+}
+
static void
launch_app (GsdMediaKeysManager *manager,
GAppInfo *app_info,
@@ -1009,6 +1036,12 @@ launch_app (GsdMediaKeysManager *manager,
gdk_app_launch_context_set_timestamp (launch_context, timestamp);
set_launch_context_env (manager, G_APP_LAUNCH_CONTEXT (launch_context));
+ g_signal_connect_object (launch_context,
+ "launched",
+ G_CALLBACK (app_launched_cb),
+ manager,
+ 0);
+
if (!g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error)) {
g_warning ("Could not launch '%s': %s",
g_app_info_get_commandline (app_info),
diff --git a/plugins/media-keys/meson.build b/plugins/media-keys/meson.build
index e6c1d2ac..cbda8eec 100644
--- a/plugins/media-keys/meson.build
+++ b/plugins/media-keys/meson.build
@@ -27,6 +27,7 @@ deps = plugins_deps + [
gsettings_desktop_dep,
libcanberra_gtk_dep,
libcommon_dep,
+ gnome_desktop_dep,
libgvc_dep,
libpulse_mainloop_glib_dep,
m_dep,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]