From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Thu, 24 Sep 2015 17:26:15 +0100
Subject: Add a systemd user service corresponding to the D-Bus session service

This lets Mission Control run in its own cgroup.

As a bonus, systemd activation doesn't have to resort to hacks like
mc-wait-for-name, because systemd understands the concept of a
systemd service that maps to multiple D-Bus service names, and will
only start it once.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92115
---
 server/Makefile.am                                          | 7 +++++++
 server/org.freedesktop.Telepathy.AccountManager.service.in  | 1 +
 server/org.freedesktop.Telepathy.MissionControl5.service.in | 1 +
 server/telepathy-mission-control-5.service.in               | 8 ++++++++
 4 files changed, 17 insertions(+)
 create mode 100644 server/telepathy-mission-control-5.service.in

diff --git a/server/Makefile.am b/server/Makefile.am
index 5be1cdc..0235db3 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -12,15 +12,22 @@ AM_CFLAGS = $(ERROR_CFLAGS)
 
 EXTRA_DIST = org.freedesktop.Telepathy.MissionControl5.service.in \
 	     org.freedesktop.Telepathy.AccountManager.service.in \
+	     telepathy-mission-control-5.service.in \
 	     mission-control-5.8.in
 CLEANFILES = org.freedesktop.Telepathy.MissionControl5.service \
 	     org.freedesktop.Telepathy.AccountManager.service \
+	     telepathy-mission-control-5.service \
 	     mission-control-5.8
 
 servicefiledir=$(prefix)/share/dbus-1/services
 servicefile_DATA=org.freedesktop.Telepathy.MissionControl5.service \
 		 org.freedesktop.Telepathy.AccountManager.service
 
+systemd_user_unitdir = $(prefix)/lib/systemd/user
+systemd_user_unit_DATA = \
+	telepathy-mission-control-5.service \
+	$(NULL)
+
 %.service: %.service.in Makefile
 	$(AM_V_GEN)sed \
 		-e 's![@]libexecdir[@]!$(libexecdir)!' \
diff --git a/server/org.freedesktop.Telepathy.AccountManager.service.in b/server/org.freedesktop.Telepathy.AccountManager.service.in
index c137820..773aaf6 100644
--- a/server/org.freedesktop.Telepathy.AccountManager.service.in
+++ b/server/org.freedesktop.Telepathy.AccountManager.service.in
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=org.freedesktop.Telepathy.AccountManager
 Exec=@libexecdir@/mission-control-5
+SystemdService=telepathy-mission-control-5.service
diff --git a/server/org.freedesktop.Telepathy.MissionControl5.service.in b/server/org.freedesktop.Telepathy.MissionControl5.service.in
index 51f4dc1..dcc470f 100644
--- a/server/org.freedesktop.Telepathy.MissionControl5.service.in
+++ b/server/org.freedesktop.Telepathy.MissionControl5.service.in
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=org.freedesktop.Telepathy.MissionControl5
 Exec=@bindir@/mc-wait-for-name --activate org.freedesktop.Telepathy.AccountManager org.freedesktop.Telepathy.MissionControl5
+SystemdService=telepathy-mission-control-5.service
diff --git a/server/telepathy-mission-control-5.service.in b/server/telepathy-mission-control-5.service.in
new file mode 100644
index 0000000..b99bd14
--- /dev/null
+++ b/server/telepathy-mission-control-5.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=Telepathy Mission Control service
+Documentation=man:mission-control-5(8)
+
+[Service]
+Type=dbus
+BusName=org.freedesktop.Telepathy.AccountManager
+ExecStart=@libexecdir@/mission-control-5