on xenial help sign in
First (unfinished) pass at systemd unit for unity8
commitdb671170306e886d96de172a2b8b3cd68c33e58d authorMichael Terry <michael.terry@canonical.com> dateWed 29 Mar 2017, 09:34 (10 years ago) parent0ab2b1c
11 files changed+72−27
data/unity8-session+45 data/unity8.service+11 debian/control+2−1 debian/unity8.install+2−1 plugins/Unity/Session/dbusunitysessionservice.cpp+5−11 tests/plugins/Unity/Session/CMakeLists.txt+1 tests/plugins/Unity/Session/LogindServer.cpp−5 tests/plugins/Unity/Session/LogindServer.h−1 tests/plugins/Unity/Session/interfaces.xml−4 tests/plugins/Unity/Session/server.cpp+1−1 tests/plugins/Unity/Session/sessionbackendtest.cpp+5−3
data/unity8-sessionnew file+45
@@ -0,0 +1,45 @@
1+#!/bin/sh
2+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
3+
4+# Ensure the shell always gets unthrottled touch events, so that applications
5+# who want full speed low-latency input can get it (LP: #1497105) and so that
6+# apps can use QML touch compression safely (the QML touch compression
7+# algorithm does not support nesting well - LP: #1486341, LP: #1556763 - so
8+# must be fed by the raw input event stream from Unity8).
9+export QML_NO_TOUCH_COMPRESSION=1
10+
11+export MIR_SERVER_PROMPT_FILE=1
12+
13+# Hard code socket path because our snappy apparmor profile
14+# only lets us put the socket in one place. And consumers expect it there.
15+# (XDG_RUNTIME_DIR isn't typical under snappy)
16+export MIR_SERVER_FILE=/run/user/$(id -u)/mir_socket
17+
18+rm -f "$MIR_SERVER_FILE"
19+rm -f "${MIR_SERVER_FILE}_trusted"
20+
21+if [ "$XDG_SESSION_DESKTOP" = "ubuntu-touch" ]; then
22+ # On Ubuntu Touch, we currently use a trick where we auto-login the
23+ # user without a LightDM greeter at all. In this case, we want to
24+ # start with the lockscreen visible. Once we switch to using a
25+ # proper greeter for the first login, we can remove this code path.
26+ MODE=full-greeter
27+else
28+ MODE=full-shell
29+fi
30+
31+dbus-update-activation-environment --systemd MIR_SOCKET=$MIR_SERVER_FILE
32+
33+# Tell unity-mir to raise SIGSTOP after we start, which we use to tell
34+# systemd when we are done starting up.
35+export UNITY_MIR_EMITS_SIGSTOP=1
36+
37+trap 'exit 0' USR1
38+
39+(trap 'kill -CONT $$; kill -USR1 $(jobs -p)' STOP;
40+ exec ${BINARY:-unity8} --mode=$MODE "$@") &
41+
42+#FIXME -- we keep hitting this timeout
43+sleep 30 # timeout for u8 startup (change to 'infinity' to disable timeout)
44+echo "Aborting unity8 launch: didn't hear back from Mir"
45+exit 100
data/unity8.servicenew file+11
@@ -0,0 +1,11 @@
1+[Unit]
2+Description=Unity Shell v8
3+PartOf=graphical-session.target
4+Requires=dbus.socket
5+After=dbus.socket
6+
7+[Service]
8+Type=forking
9+ExecStart=/usr/bin/unity8-session
10+ExecStopPost=/usr/bin/dbus-update-activation-environment --systemd MIR_SOCKET=
11+Restart=on-failure
debian/control+2−1
@@ -120,7 +120,8 @@ Description: Development tool for Unity scopes
120120Package: unity8
121121Architecture: any
122122Provides: indicator-renderer,
123−Depends: dmz-cursor-theme,
123+Depends: dbus,
124+ dmz-cursor-theme,
124125 gsettings-desktop-schemas,
125126 libcap2-bin,
126127 libglib2.0-bin,
debian/unity8.install+2−1
@@ -1,7 +1,8 @@
11debian/usr.bin.unity8-dash etc/apparmor.d
22var/lib/unity8/version
33data/unity8-filewatcher.conf usr/share/upstart/sessions/
4−data/unity8.conf usr/share/upstart/sessions/
4+data/unity8.service usr/lib/systemd/user
5+data/unity8-session usr/bin
56data/devices.conf etc/ubuntu/
67data/test.sensors etc/ubuntusensors/
78usr/bin/unity8
plugins/Unity/Session/dbusunitysessionservice.cpp+5−11
@@ -36,6 +36,7 @@
3636
3737#define LOGIN1_SERVICE QStringLiteral("org.freedesktop.login1")
3838#define LOGIN1_PATH QStringLiteral("/org/freedesktop/login1")
39+#define LOGIN1_SESSION_ROOT QStringLiteral("/org/freedesktop/login1/session/")
3940#define LOGIN1_IFACE QStringLiteral("org.freedesktop.login1.Manager")
4041#define LOGIN1_SESSION_IFACE QStringLiteral("org.freedesktop.login1.Session")
4142
@@ -58,16 +59,9 @@ public:
5859
5960 void init()
6061 {
61− // get our logind session path
62− QDBusMessage msg = QDBusMessage::createMethodCall(LOGIN1_SERVICE,
63− LOGIN1_PATH,
64− LOGIN1_IFACE,
65− QStringLiteral("GetSessionByPID"));
66− msg << (quint32) getpid();
67−
68− QDBusReply<QDBusObjectPath> reply = QDBusConnection::SM_BUSNAME().call(msg);
69− if (reply.isValid()) {
70− logindSessionPath = reply.value().path();
62+ QString sessionID = QString::fromLocal8Bit(qgetenv("XDG_SESSION_ID"));
63+ if (!sessionID.isEmpty()) {
64+ logindSessionPath = LOGIN1_SESSION_ROOT + sessionID;
7165
7266 // start watching the Active property
7367 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
@@ -79,7 +73,7 @@ public:
7973 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
8074 this, SLOT(onResuming(bool)));
8175 } else {
82− qWarning() << "Failed to get logind session path" << reply.error().message();
76+ qWarning() << "Failed to get logind session: XDG_SESSION_ID is not set";
8377 }
8478 }
8579
tests/plugins/Unity/Session/CMakeLists.txt+1
@@ -60,6 +60,7 @@ install(TARGETS sessionbackendtestExec
6060
6161add_unity8_unittest(SessionBackend dbus-test-runner
6262 ENVIRONMENT LD_PRELOAD=$<TARGET_FILE:SessionBackendTestPreload>
63+ XDG_SESSION_ID=testing
6364 XDG_SESSION_PATH=/session
6465 ARG_PREFIX "--parameter"
6566 ARGS
tests/plugins/Unity/Session/LogindServer.cpp−5
@@ -22,11 +22,6 @@ LogindServer::LogindServer(QObject *parent)
2222{
2323}
2424
25−QDBusObjectPath LogindServer::GetSessionByPID(quint32)
26−{
27− return QDBusObjectPath("/logindsession");
28−}
29−
3025void LogindServer::Reboot(bool interactive)
3126{
3227 Q_EMIT RebootCalled(interactive);
tests/plugins/Unity/Session/LogindServer.h−1
@@ -30,7 +30,6 @@ public:
3030 explicit LogindServer(QObject *parent = nullptr);
3131
3232public Q_SLOTS:
33− QDBusObjectPath GetSessionByPID(quint32 pid);
3433 void Reboot(bool interactive);
3534 void PowerOff(bool interactive);
3635
tests/plugins/Unity/Session/interfaces.xml−4
@@ -3,10 +3,6 @@
33 <method name="Lock" />
44 </interface>
55 <interface name="org.freedesktop.login1.Manager">
6− <method name="GetSessionByPID">
7− <arg name="pid" type="u" direction="in" />
8− <arg name="session" type="o" direction="out" />
9− </method>
106 <method name="Reboot">
117 <arg name="interactive" type="b" direction="in" />
128 </method>
tests/plugins/Unity/Session/server.cpp+1−1
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
3737 auto connection = QDBusConnection::sessionBus();
3838 if (!connection.registerObject("/org/freedesktop/login1", logind))
3939 return 1;
40− if (!connection.registerObject("/logindsession", logind))
40+ if (!connection.registerObject("/org/freedesktop/login1/session/testing", logind))
4141 return 1;
4242 if (!connection.registerService("org.freedesktop.login1"))
4343 return 1;
tests/plugins/Unity/Session/sessionbackendtest.cpp+5−3
@@ -103,8 +103,8 @@ private Q_SLOTS:
103103 QCoreApplication::processEvents(); // to let the services register on DBus
104104
105105 QDBusInterface login1Interface("org.freedesktop.login1",
106− "/logindsession",
107− "org.freedesktop.login1.Manager");
106+ "/org/freedesktop/login1/session/testing",
107+ "org.freedesktop.login1.Manager");
108108 QSignalSpy spy(&login1Interface, signal.toUtf8().data());
109109
110110 QDBusInterface dbusGnomeSessionWrapper("org.gnome.SessionManager",
@@ -225,7 +225,9 @@ private Q_SLOTS:
225225 DBusUnitySessionService dbusUnitySessionService;
226226 QCoreApplication::processEvents(); // to let the service register on DBus
227227
228− QDBusInterface iface("org.freedesktop.login1", "/logindsession", "org.freedesktop.login1.Session");
228+ QDBusInterface iface("org.freedesktop.login1",
229+ "/org/freedesktop/login1/session/testing",
230+ "org.freedesktop.login1.Session");
229231 QVERIFY(iface.isValid());
230232
231233 QSignalSpy spy(&dbusUnitySessionService, SIGNAL(Unlocked()));