on xenial help sign in
First (unfinished) pass at systemd unit for unity8
db67117Michael Terry
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
120Package: unity8
120Package: unity8
121Architecture: any
121Architecture: any
122Provides: indicator-renderer,
122Provides: indicator-renderer,
123+Depends: dbus,
123−Depends: dmz-cursor-theme,
124+ dmz-cursor-theme,
124 gsettings-desktop-schemas,
125 gsettings-desktop-schemas,
125 libcap2-bin,
126 libcap2-bin,
126 libglib2.0-bin,
127 libglib2.0-bin,
debian/unity8.install+2−1
@@ -1,7 +1,8 @@
1debian/usr.bin.unity8-dash etc/apparmor.d
1debian/usr.bin.unity8-dash etc/apparmor.d
2var/lib/unity8/version
2var/lib/unity8/version
3data/unity8-filewatcher.conf usr/share/upstart/sessions/
3data/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
5data/devices.conf etc/ubuntu/
6data/devices.conf etc/ubuntu/
6data/test.sensors etc/ubuntusensors/
7data/test.sensors etc/ubuntusensors/
7usr/bin/unity8
8usr/bin/unity8
plugins/Unity/Session/dbusunitysessionservice.cpp+5−11
@@ -36,6 +36,7 @@
36
36
37#define LOGIN1_SERVICE QStringLiteral("org.freedesktop.login1")
37#define LOGIN1_SERVICE QStringLiteral("org.freedesktop.login1")
38#define LOGIN1_PATH QStringLiteral("/org/freedesktop/login1")
38#define LOGIN1_PATH QStringLiteral("/org/freedesktop/login1")
39+#define LOGIN1_SESSION_ROOT QStringLiteral("/org/freedesktop/login1/session/")
39#define LOGIN1_IFACE QStringLiteral("org.freedesktop.login1.Manager")
40#define LOGIN1_IFACE QStringLiteral("org.freedesktop.login1.Manager")
40#define LOGIN1_SESSION_IFACE QStringLiteral("org.freedesktop.login1.Session")
41#define LOGIN1_SESSION_IFACE QStringLiteral("org.freedesktop.login1.Session")
41
42
@@ -58,16 +59,9 @@ public:
58
59
59 void init()
60 void init()
60 {
61 {
61− // get our logind session path
62+ QString sessionID = QString::fromLocal8Bit(qgetenv("XDG_SESSION_ID"));
62− QDBusMessage msg = QDBusMessage::createMethodCall(LOGIN1_SERVICE,
63+ if (!sessionID.isEmpty()) {
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();
64+ logindSessionPath = LOGIN1_SESSION_ROOT + sessionID;
71
65
72 // start watching the Active property
66 // start watching the Active property
73 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
67 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
@@ -79,7 +73,7 @@ public:
79 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
73 QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
80 this, SLOT(onResuming(bool)));
74 this, SLOT(onResuming(bool)));
81 } else {
75 } 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";
83 }
77 }
84 }
78 }
85
79
tests/plugins/Unity/Session/CMakeLists.txt+1
@@ -60,6 +60,7 @@ install(TARGETS sessionbackendtestExec
60
60
61add_unity8_unittest(SessionBackend dbus-test-runner
61add_unity8_unittest(SessionBackend dbus-test-runner
62 ENVIRONMENT LD_PRELOAD=$<TARGET_FILE:SessionBackendTestPreload>
62 ENVIRONMENT LD_PRELOAD=$<TARGET_FILE:SessionBackendTestPreload>
63+ XDG_SESSION_ID=testing
63 XDG_SESSION_PATH=/session
64 XDG_SESSION_PATH=/session
64 ARG_PREFIX "--parameter"
65 ARG_PREFIX "--parameter"
65 ARGS
66 ARGS
tests/plugins/Unity/Session/LogindServer.cpp−5
@@ -22,11 +22,6 @@ LogindServer::LogindServer(QObject *parent)
22{
22{
23}
23}
24
24
25−QDBusObjectPath LogindServer::GetSessionByPID(quint32)
26−{
27− return QDBusObjectPath("/logindsession");
28−}
29−
30void LogindServer::Reboot(bool interactive)
25void LogindServer::Reboot(bool interactive)
31{
26{
32 Q_EMIT RebootCalled(interactive);
27 Q_EMIT RebootCalled(interactive);
tests/plugins/Unity/Session/LogindServer.h−1
@@ -30,7 +30,6 @@ public:
30 explicit LogindServer(QObject *parent = nullptr);
30 explicit LogindServer(QObject *parent = nullptr);
31
31
32public Q_SLOTS:
32public Q_SLOTS:
33− QDBusObjectPath GetSessionByPID(quint32 pid);
34 void Reboot(bool interactive);
33 void Reboot(bool interactive);
35 void PowerOff(bool interactive);
34 void PowerOff(bool interactive);
36
35
tests/plugins/Unity/Session/interfaces.xml−4
@@ -3,10 +3,6 @@
3 <method name="Lock" />
3 <method name="Lock" />
4 </interface>
4 </interface>
5 <interface name="org.freedesktop.login1.Manager">
5 <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>
10 <method name="Reboot">
6 <method name="Reboot">
11 <arg name="interactive" type="b" direction="in" />
7 <arg name="interactive" type="b" direction="in" />
12 </method>
8 </method>
tests/plugins/Unity/Session/server.cpp+1−1
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
37 auto connection = QDBusConnection::sessionBus();
37 auto connection = QDBusConnection::sessionBus();
38 if (!connection.registerObject("/org/freedesktop/login1", logind))
38 if (!connection.registerObject("/org/freedesktop/login1", logind))
39 return 1;
39 return 1;
40− if (!connection.registerObject("/logindsession", logind))
40+ if (!connection.registerObject("/org/freedesktop/login1/session/testing", logind))
41 return 1;
41 return 1;
42 if (!connection.registerService("org.freedesktop.login1"))
42 if (!connection.registerService("org.freedesktop.login1"))
43 return 1;
43 return 1;
tests/plugins/Unity/Session/sessionbackendtest.cpp+5−3
@@ -103,8 +103,8 @@ private Q_SLOTS:
103 QCoreApplication::processEvents(); // to let the services register on DBus
103 QCoreApplication::processEvents(); // to let the services register on DBus
104
104
105 QDBusInterface login1Interface("org.freedesktop.login1",
105 QDBusInterface login1Interface("org.freedesktop.login1",
106− "/logindsession",
106+ "/org/freedesktop/login1/session/testing",
107− "org.freedesktop.login1.Manager");
107+ "org.freedesktop.login1.Manager");
108 QSignalSpy spy(&login1Interface, signal.toUtf8().data());
108 QSignalSpy spy(&login1Interface, signal.toUtf8().data());
109
109
110 QDBusInterface dbusGnomeSessionWrapper("org.gnome.SessionManager",
110 QDBusInterface dbusGnomeSessionWrapper("org.gnome.SessionManager",
@@ -225,7 +225,9 @@ private Q_SLOTS:
225 DBusUnitySessionService dbusUnitySessionService;
225 DBusUnitySessionService dbusUnitySessionService;
226 QCoreApplication::processEvents(); // to let the service register on DBus
226 QCoreApplication::processEvents(); // to let the service register on DBus
227
227
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");
229 QVERIFY(iface.isValid());
231 QVERIFY(iface.isValid());
230
232
231 QSignalSpy spy(&dbusUnitySessionService, SIGNAL(Unlocked()));
233 QSignalSpy spy(&dbusUnitySessionService, SIGNAL(Unlocked()));