Merge lp:~ted/unity/systemd-unit. into lp:unity

Proposed by Ted Gould on 2016-07-20
Status: Superseded
Proposed branch: lp:~ted/unity/systemd-unit.
Merge into: lp:unity
Prerequisite: lp:~azzar1/unity/unity-active-plugins--safety-check
Diff against target: 741 lines (+433/-47)
25 files modified
CMakeLists.txt (+11/-1)
debian/control (+22/-20)
debian/libunity-core-6.0-9.install (+3/-2)
debian/unity-services.install (+4/-1)
debian/unity-services.links (+13/-0)
debian/unity.install (+3/-0)
lockscreen/LockScreenController.cpp (+4/-0)
lockscreen/LockScreenController.h (+3/-0)
services/CMakeLists.txt (+31/-0)
services/unity-panel-service-lockscreen.override (+1/-0)
services/unity-panel-service-lockscreen.service.in (+7/-0)
services/unity-panel-service.override (+1/-0)
services/unity-panel-service.service.in (+9/-0)
services/unity-screen-locked.target (+4/-0)
tests/CMakeLists.txt (+1/-0)
tests/test_lockscreen_controller.cpp (+5/-2)
tests/test_systemd_wrapper.cpp (+111/-0)
tools/CMakeLists.txt (+3/-0)
tools/unity-compiz-profile-select.in (+25/-0)
unity-shared/CMakeLists.txt (+1/-0)
unity-shared/SystemdWrapper.cpp (+103/-0)
unity-shared/SystemdWrapper.h (+55/-0)
unity7.conf.in (+1/-21)
unity7.override (+1/-0)
unity7.service.in (+11/-0)
To merge this branch: bzr merge lp:~ted/unity/systemd-unit.
Reviewer Review Type Date Requested Status
Iain Lane Needs Fixing on 2016-08-31
Marco Trevisan (Treviño) 2016-07-20 Needs Fixing on 2016-08-25
Review via email: mp+300624@code.launchpad.net

This proposal supersedes a proposal from 2016-07-20.

This proposal has been superseded by a proposal from 2016-09-02.

Commit Message

Adding systemd user session units

Description of the Change

At it's core this MR is about making unity7 work with the systemd user sessions. It required a larger change than expected, so some descriptions :-)

It moves the prestart scripts from Upstart into a shared shell script so that both systemd and Upstart can use the same code.

Added a signal wrapper for Systemd, today we are sending both signals as both will be running for the time being. In the future the Upstart signals should be droppable.

For lock screen we created a target for when the lock screen is enabled. We put the panel job in there, but other jobs can add themselves by putting a symbolic link into the "unity-screen-locked.target.wants" directory to their jobs if they want.

To post a comment you must log in.
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal

There have been changes recently to upstart job to change COMPIZ_CONFIG_PROFILE depending on the gfx environment. So please sync with upstream changes on that.

Also, please rebase on lp:~azzar1/unity/unity-active-plugins--safety-check, which will need to be ported too

Marco Trevisan (Treviño) (3v1n0) wrote :

I don't see unity-compiz-profile in any .install file.

Please move that into unity.install together with systemd (and unity7.conf file). I don't remember why they were added there in the past (likely for some gsettings and unity8 dependency on libunity-core), but I think that is not the nicest places to be.

Marco Trevisan (Treviño) (3v1n0) wrote :

Can you please merge this again with lp:~azzar1/unity/unity-active-plugins--safety-check?

It should be the last time :-)

Marco Trevisan (Treviño) (3v1n0) wrote :

As per channel discussion:

15:15:38 <Trevinho> tedg: also, I was thinking... using that code in the current yakkety causes the Start/Stop calls to not happen since the proxy is not connected... They get queued though... Maybe you could avoid to call start/stop if the systemd_proxy_ is not connected?
15:16:37 <Trevinho> tedg: at the beginning I had the idea of just provinding one of the two wrappers, depending on what is running in the session, but... It's a little to annoying, and I didn't want you to create an abstract class just for that, but... Maybe...
15:16:55 <tedg> Trevinho: Oh, because it's connecting to the session bus instead of the user bus right now?
15:17:04 <Trevinho> tedg: yes
15:17:14 <tedg> Trevinho: We won't have the Upstart stuff for long hopefully, so I don't think it's worth abstracting.
15:18:18 <Trevinho> tedg: yeah, same I thought...
15:18:36 <Trevinho> tedg: but currently guess we'd get some "Timed out waiting for proxy" erros in unity logs
15:18:37 <Trevinho> so...
15:19:11 <Trevinho> tedg: is an env var available when systemd is there?
15:19:55 <tedg> tedg: I think checking if it's connected is fine. We can drop that too once we get migrated over if it's taking too long.
15:20:03 <Trevinho> ok...
15:20:30 <Trevinho> tedg: I mean, it might be not connected at the very start of the session... Like if starting with unity already locked (because of a crash) though
15:20:48 <Trevinho> but... Yeah, as you say, this is something we can get rid of
15:21:08 <Trevinho> or, juts check for an env var presency for both upstart and systemd wrappers
15:23:01 <Trevinho> tedg: also /usr/share/unity/unity-compiz-profile I'd prefer it to be in /usr/lib/unity
15:24:04 <Trevinho> tedg: and probably renamed unity-compiz-profile-set or -selector or... anything that explains better :-)
15:25:05 <tedg> K, I was avoiding changing the codebase too much, but since andyrock moved the .conf file into the build system we can move it to lib.
15:33:32 <Trevinho> tedg: yeah, that's nicer

Ted Gould (ted) wrote :

K, I think that's everything :-)

Marco Trevisan (Treviño) (3v1n0) wrote :

Still some conflicts with the parent branch, merge again please...

Marco Trevisan (Treviño) (3v1n0) wrote :

Also, you want me to land this or you prefer to land the branch together with the other systemd branches?

Marco Trevisan (Treviño) (3v1n0) wrote :

Looks good, just still wondering if you can get rid of that static list from the .service :)

Ted Gould (ted) wrote :

So I removed the list and put it as a set of symbolic links in the packaging. At least then it is a packaging thing (when suggests change the links should change) more than an Upstream thing.

Marco Trevisan (Treviño) (3v1n0) wrote :

Mh, this is better... I would have guessed this was done at each indicator level, but I can go with this too.

One only minor thing, it shouldn't never happen that the lockscreen is there without ups running, but... For safety I think it would be better to also add

/usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-datetime.service
/usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-keyboard.service
/usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-power.service
/usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-session.service
/usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-sound.service

Ted Gould (ted) wrote :

On Tue, 2016-08-09 at 16:09 +0000, Marco Trevisan (Treviño) wrote:
> Mh, this is better... I would have guessed this was done at each
> indicator level, but I can go with this too.
Yes, systemd is "backwards" to Upstart in that you define a state and
how to achieve that state instead of an event that you listen for. So
the state is panel-service running and you achieve that by starting the
indicators instead of the panel service asking the indicators to start.
I miss Upstart, I think it made more sense too :-(
> One only minor thing, it shouldn't never happen that the lockscreen is there without ups running, but... For safety I think it would be better to also add
>

Yup, good idea, added.

Marco Trevisan (Treviño) (3v1n0) wrote :

Nice, I think we can land this now!

review: Approve
Marco Trevisan (Treviño) (3v1n0) wrote :

Ouch, I'm getting this now:

dpkg: error processing archive /tmp/apt-dpkg-install-pcRES4/3-unity_7.5.0+16.10.20160823-0ubuntu1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/unity/makebootchart.py', which is also in package libunity-core-6.0-9:amd64 7.5.0+16.10.20160817.1-0ubuntu1

I guess this is because the unity.install +usr/lib/*/unity line, can you set it as it used to be please?

review: Needs Fixing
lp:~ted/unity/systemd-unit. updated on 2016-08-30
4180. By Ted Gould on 2016-08-30

Explicitly list binaries in unity.install

Ted Gould (ted) wrote :

Set them up to explicitly mention, looks like they end up in the right package now.

lp:~ted/unity/systemd-unit. updated on 2016-08-30
4181. By Ted Gould on 2016-08-30

Remove pre dot

Marco Trevisan (Treviño) (3v1n0) wrote :

I didn't generated scripts have wrong path, you should use FULL_LIBDIR.

[/usr/lib/systemd/user/unity7.service:10] Executable path is not absolute, ignoring: lib/x86_64-linux-gnu/unity/unity-compiz-profile-select

lp:~ted/unity/systemd-unit. updated on 2016-08-31
4182. By Ted Gould on 2016-08-31

Use the full libdir

4183. By Ted Gould on 2016-08-31

Ensure the profile select tool works

Marco Trevisan (Treviño) (3v1n0) wrote :

The prefixes on the .service and .config files are still wrong... See the inline comments.

Also unity7 doesn't start automatically (it does if I use systemctl manually), and I also see this:

 indicator-application.service not-found inactive dead indicator-application.service
● indicator-bluetooth.service not-found inactive dead indicator-bluetooth.service
● indicator-datetime.service not-found inactive dead indicator-datetime.service
● indicator-keyboard.service not-found inactive dead indicator-keyboard.service
● indicator-messages.service not-found inactive dead indicator-messages.service
● indicator-power.service not-found inactive dead indicator-power.service
● indicator-session.service not-found inactive dead indicator-session.service
● indicator-sound.service not-found inactive dead indicator-sound.service
  unity-gtk-module.service loaded active exited Unity GTK Module Environment variables
  unity-panel-service.service loaded inactive dead Backing Service for the Unity Panel
  unity-settings-daemon.service loaded active running Unity Settings Daemon
  unity7.service loaded inactive dead Unity Shell v7
  indicators-pre.target loaded inactive dead

Iain Lane (laney) wrote :

Missing:

  - symlink /usr/lib/systemd/user/ubuntu-session.target.requires/unity7.service -> ../unity7.service
  - Environment=COMPIZ_CONFIG_PROFILE=ubuntu

review: Needs Fixing
Marco Trevisan (Treviño) (3v1n0) wrote :

> - Environment=COMPIZ_CONFIG_PROFILE=ubuntu

This isn't true anymore, since the profile could also be ubnutu-lowgfx, so this has to be done from the pre-start script

Marco Trevisan (Treviño) (3v1n0) wrote :

> - Environment=COMPIZ_CONFIG_PROFILE=ubuntu

This isn't true anymore, since the profile could also be ubnutu-lowgfx, so this has to be done from the pre-start script

Iain Lane (laney) wrote :

On Wed, Aug 31, 2016 at 10:54:22AM -0000, Marco Trevisan (Treviño) wrote:
> > - Environment=COMPIZ_CONFIG_PROFILE=ubuntu
>
> This isn't true anymore, since the profile could also be ubnutu-lowgfx, so this has to be done from the pre-start script

Then make that call dbus-update-activation-environment

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Iain Lane (laney) wrote :

On Wed, Aug 31, 2016 at 11:03:38AM -0000, Iain Lane wrote:
> On Wed, Aug 31, 2016 at 10:54:22AM -0000, Marco Trevisan (Treviño) wrote:
> > > - Environment=COMPIZ_CONFIG_PROFILE=ubuntu
> >
> > This isn't true anymore, since the profile could also be ubnutu-lowgfx, so this has to be done from the pre-start script
>
> Then make that call dbus-update-activation-environment

instead of systemctl set-environment, that is. Most jobs do

  initctl set-env -g ...
  dbus-update-activation-environment --verbose --systemd VAR

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-07-21 13:01:59 +0000
3+++ CMakeLists.txt 2016-08-31 03:25:56 +0000
4@@ -429,5 +429,15 @@
5 #
6 # Upstart
7 #
8-configure_file(unity7.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf)
9+
10+configure_file(unity7.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf @ONLY)
11 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
12+
13+#
14+# Systemd
15+#
16+
17+configure_file(unity7.service.in ${CMAKE_CURRENT_BINARY_DIR}/unity7.service @ONLY)
18+pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
19+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity7.service DESTINATION ${SYSTEMD_USER_DIR})
20+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/unity7.override DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/systemd-session/upstart)
21
22=== modified file 'debian/control'
23--- debian/control 2016-07-25 18:20:16 +0000
24+++ debian/control 2016-08-31 03:25:56 +0000
25@@ -53,6 +53,7 @@
26 python3 (>= 3.4),
27 python-setuptools,
28 quilt,
29+ systemd,
30 xserver-xorg-video-dummy,
31 xsltproc,
32 Standards-Version: 3.9.5
33@@ -81,12 +82,31 @@
34 libxfixes3 (>= 1:5.0.1-1),
35 libxi6 (>= 2:1.7.1.901),
36 unity-scope-home,
37-Provides: indicator-renderer
38 Recommends: unity-control-center,
39 ${unity-default-masterscopes}
40 nautilus,
41 gnome-disk-utility,
42- indicator-appmenu (>= 15.02.0),
43+ hud,
44+ session-shortcuts,
45+Breaks: unity-lens-applications (<< 5.12.0-0ubuntu2),
46+ unity-lens-files (<< 5.10.0-0ubuntu2),
47+ unity-lens-music (<< 6.0.0),
48+ unity-lens-video (<< 0.3.6-0ubuntu2),
49+Description: Interface designed for efficiency of space and interaction.
50+ Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
51+ community, Unity is all about the combination of familiarity and the future. We
52+ bring together visual design, analysis of user experience testing, modern
53+ graphics technologies and a deep understanding of the free software landscape
54+ to produce what we hope will be the lightest, most elegant and most delightful
55+ way to use your PC.
56+
57+Package: unity-services
58+Architecture: any
59+Depends: ${shlibs:Depends},
60+ ${misc:Depends},
61+ indicator-common,
62+Provides: indicator-renderer
63+Recommends: indicator-appmenu (>= 15.02.0),
64 indicator-application,
65 indicator-sound,
66 indicator-bluetooth,
67@@ -96,24 +116,6 @@
68 indicator-printers,
69 indicator-power,
70 indicator-session,
71- hud,
72- session-shortcuts,
73-Breaks: unity-lens-applications (<< 5.12.0-0ubuntu2),
74- unity-lens-files (<< 5.10.0-0ubuntu2),
75- unity-lens-music (<< 6.0.0),
76- unity-lens-video (<< 0.3.6-0ubuntu2),
77-Description: Interface designed for efficiency of space and interaction.
78- Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
79- community, Unity is all about the combination of familiarity and the future. We
80- bring together visual design, analysis of user experience testing, modern
81- graphics technologies and a deep understanding of the free software landscape
82- to produce what we hope will be the lightest, most elegant and most delightful
83- way to use your PC.
84-
85-Package: unity-services
86-Architecture: any
87-Depends: ${shlibs:Depends},
88- ${misc:Depends},
89 Description: Services for the Unity interface
90 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
91 community, Unity is all about the combination of familiarity and the future. We
92
93=== modified file 'debian/libunity-core-6.0-9.install'
94--- debian/libunity-core-6.0-9.install 2016-07-26 16:45:34 +0000
95+++ debian/libunity-core-6.0-9.install 2016-08-31 03:25:56 +0000
96@@ -2,8 +2,9 @@
97 usr/lib/*/unity/*.py
98 usr/share/ccsm
99 usr/share/gnome-control-center/
100-usr/share/unity
101-usr/share/upstart/sessions/unity7.conf
102+usr/share/unity/icons
103+usr/share/unity/themes
104 debian/unity-crashdb.conf etc/apport/crashdb.conf.d/
105 debian/source_unity.py usr/share/apport/package-hooks
106 tools/convert-files/* usr/lib/compiz/migration/
107+usr/share/upstart/sessions/unity7.conf
108
109=== modified file 'debian/unity-services.install'
110--- debian/unity-services.install 2016-07-26 13:58:14 +0000
111+++ debian/unity-services.install 2016-08-31 03:25:56 +0000
112@@ -1,3 +1,6 @@
113 usr/lib/*/unity/*service
114-usr/share/upstart/sessions/unity-panel-service*.conf
115+usr/share/upstart/sessions/unity-panel*
116+usr/share/upstart/systemd-session/upstart/unity-panel*
117+usr/lib/systemd/user/unity-panel*
118+usr/lib/systemd/user/unity-screen-locked.target
119 usr/share/man/*/unity-panel-service.1
120
121=== added file 'debian/unity-services.links'
122--- debian/unity-services.links 1970-01-01 00:00:00 +0000
123+++ debian/unity-services.links 2016-08-31 03:25:56 +0000
124@@ -0,0 +1,13 @@
125+/usr/lib/systemd/user/indicator-application.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-application.service
126+/usr/lib/systemd/user/indicator-bluetooth.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-bluetooth.service
127+/usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-datetime.service
128+/usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-keyboard.service
129+/usr/lib/systemd/user/indicator-messages.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-messages.service
130+/usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-power.service
131+/usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-session.service
132+/usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service.service.wants/indicator-sound.service
133+/usr/lib/systemd/user/indicator-datetime.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-datetime.service
134+/usr/lib/systemd/user/indicator-keyboard.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-keyboard.service
135+/usr/lib/systemd/user/indicator-power.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-power.service
136+/usr/lib/systemd/user/indicator-session.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-session.service
137+/usr/lib/systemd/user/indicator-sound.service /usr/lib/systemd/user/unity-panel-service-lockscreen.service.wants/indicator-sound.service
138
139=== modified file 'debian/unity.install'
140--- debian/unity.install 2016-07-26 16:45:34 +0000
141+++ debian/unity.install 2016-08-31 03:25:56 +0000
142@@ -2,6 +2,9 @@
143 usr/bin
144 usr/lib/*/compiz/libunity*.so
145 usr/lib/*/unity/unity-active-plugins-safety-check
146+usr/lib/*/unity/unity-compiz-profile-select
147 usr/share/man/*/unity.1
148 usr/share/compiz
149 usr/share/locale
150+usr/lib/systemd/user/unity7.service
151+usr/share/upstart/systemd-session/upstart/unity7.override
152
153=== modified file 'lockscreen/LockScreenController.cpp'
154--- lockscreen/LockScreenController.cpp 2016-07-04 12:45:06 +0000
155+++ lockscreen/LockScreenController.cpp 2016-08-31 03:25:56 +0000
156@@ -56,6 +56,7 @@
157 Controller::Controller(DBusManager::Ptr const& dbus_manager,
158 session::Manager::Ptr const& session_manager,
159 key::Grabber::Ptr const& key_grabber,
160+ SystemdWrapper::Ptr const& systemd_wrapper,
161 UpstartWrapper::Ptr const& upstart_wrapper,
162 ShieldFactoryInterface::Ptr const& shield_factory,
163 bool test_mode)
164@@ -63,6 +64,7 @@
165 , dbus_manager_(dbus_manager)
166 , session_manager_(session_manager)
167 , key_grabber_(key_grabber)
168+ , systemd_wrapper_(systemd_wrapper)
169 , upstart_wrapper_(upstart_wrapper)
170 , shield_factory_(shield_factory)
171 , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>())
172@@ -129,6 +131,7 @@
173 shields_.clear();
174
175 upstart_wrapper_->Emit("desktop-unlock");
176+ systemd_wrapper_->Stop("unity-screen-locked.target");
177 accelerator_controller_.reset();
178 indicators_.reset();
179 }
180@@ -464,6 +467,7 @@
181 {
182 indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();
183 upstart_wrapper_->Emit("desktop-lock");
184+ systemd_wrapper_->Stop("unity-screen-locked.target");
185
186 accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_);
187 auto activate_key = WindowManager::Default().activate_indicators_key();
188
189=== modified file 'lockscreen/LockScreenController.h'
190--- lockscreen/LockScreenController.h 2016-06-21 01:28:26 +0000
191+++ lockscreen/LockScreenController.h 2016-08-31 03:25:56 +0000
192@@ -31,6 +31,7 @@
193 #include "ScreenSaverDBusManager.h"
194 #include "unity-shared/BackgroundEffectHelper.h"
195 #include "unity-shared/KeyGrabber.h"
196+#include "unity-shared/SystemdWrapper.h"
197 #include "unity-shared/UpstartWrapper.h"
198
199 namespace unity
200@@ -46,6 +47,7 @@
201 typedef std::shared_ptr<Controller> Ptr;
202
203 Controller(DBusManager::Ptr const&, session::Manager::Ptr const&, key::Grabber::Ptr const&,
204+ SystemdWrapper::Ptr const& systemd_wrapper = std::make_shared<SystemdWrapper>(),
205 UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(),
206 ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(),
207 bool test_mode = false);
208@@ -88,6 +90,7 @@
209 key::Grabber::Ptr key_grabber_;
210 indicator::Indicators::Ptr indicators_;
211 AcceleratorController::Ptr accelerator_controller_;
212+ SystemdWrapper::Ptr systemd_wrapper_;
213 UpstartWrapper::Ptr upstart_wrapper_;
214 ShieldFactoryInterface::Ptr shield_factory_;
215 SuspendInhibitorManager::Ptr suspend_inhibitor_manager_;
216
217=== modified file 'services/CMakeLists.txt'
218--- services/CMakeLists.txt 2016-02-09 01:26:22 +0000
219+++ services/CMakeLists.txt 2016-08-31 03:25:56 +0000
220@@ -58,3 +58,34 @@
221
222 configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf)
223 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
224+
225+##
226+## Systemd Unit Files
227+##
228+
229+# where to install
230+# Uncomment when we drop Vivid
231+# pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
232+set (SYSTEMD_USER_DIR "/usr/lib/systemd/user")
233+message (STATUS "${SYSTEMD_USER_DIR} is the systemd user unit file install dir")
234+
235+configure_file (unity-panel-service.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service")
236+configure_file (unity-panel-service-lockscreen.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service")
237+
238+install( FILES
239+ "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service"
240+ "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service"
241+ "${CMAKE_CURRENT_SOURCE_DIR}/unity-screen-locked.target"
242+ DESTINATION "${SYSTEMD_USER_DIR}")
243+
244+##
245+## Upstart systemd override Job File
246+##
247+
248+set (UPSTART_SYSTEMD_OVERRIDE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/upstart/systemd-session/upstart")
249+message (STATUS "${UPSTART_SYSTEMD_OVERRIDE_DIR} is the Upstart override Job File for systemd dir")
250+
251+install (FILES
252+ unity-panel-service.override
253+ unity-panel-service-lockscreen.override
254+ DESTINATION "${UPSTART_SYSTEMD_OVERRIDE_DIR}")
255
256=== added file 'services/unity-panel-service-lockscreen.override'
257--- services/unity-panel-service-lockscreen.override 1970-01-01 00:00:00 +0000
258+++ services/unity-panel-service-lockscreen.override 2016-08-31 03:25:56 +0000
259@@ -0,0 +1,1 @@
260+manual
261
262=== added file 'services/unity-panel-service-lockscreen.service.in'
263--- services/unity-panel-service-lockscreen.service.in 1970-01-01 00:00:00 +0000
264+++ services/unity-panel-service-lockscreen.service.in 2016-08-31 03:25:56 +0000
265@@ -0,0 +1,7 @@
266+[Unit]
267+Description=Backing Service for the Unity Panel in Lockscreen mode
268+PartOf=unity-screen-locked.target
269+
270+[Service]
271+ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service --lockscreen-mode
272+Restart=on-failure
273
274=== added file 'services/unity-panel-service.override'
275--- services/unity-panel-service.override 1970-01-01 00:00:00 +0000
276+++ services/unity-panel-service.override 2016-08-31 03:25:56 +0000
277@@ -0,0 +1,1 @@
278+manual
279
280=== added file 'services/unity-panel-service.service.in'
281--- services/unity-panel-service.service.in 1970-01-01 00:00:00 +0000
282+++ services/unity-panel-service.service.in 2016-08-31 03:25:56 +0000
283@@ -0,0 +1,9 @@
284+[Unit]
285+Description=Backing Service for the Unity Panel
286+After=unity7.service
287+PartOf=graphical-session.target
288+BindsTo=indicators-pre.target
289+
290+[Service]
291+ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service
292+Restart=on-failure
293
294=== added file 'services/unity-screen-locked.target'
295--- services/unity-screen-locked.target 1970-01-01 00:00:00 +0000
296+++ services/unity-screen-locked.target 2016-08-31 03:25:56 +0000
297@@ -0,0 +1,4 @@
298+[Unit]
299+Description=A target that, when running, represents the screen being locked
300+Wants=ubuntu-panel-service-lock.service
301+PartOf=graphical-session.target
302
303=== modified file 'tests/CMakeLists.txt'
304--- tests/CMakeLists.txt 2015-12-17 22:32:37 +0000
305+++ tests/CMakeLists.txt 2016-08-31 03:25:56 +0000
306@@ -286,6 +286,7 @@
307 test_switcher_controller_class.cpp
308 test_switcher_model.cpp
309 test_switcher_view.cpp
310+ test_systemd_wrapper.cpp
311 test_tabiterator.cpp
312 test_texture_cache.cpp
313 test_text_input.cpp
314
315=== modified file 'tests/test_lockscreen_controller.cpp'
316--- tests/test_lockscreen_controller.cpp 2016-06-21 14:40:26 +0000
317+++ tests/test_lockscreen_controller.cpp 2016-08-31 03:25:56 +0000
318@@ -83,9 +83,10 @@
319 , session_manager(std::make_shared<NiceMock<session::MockManager>>())
320 , key_grabber(std::make_shared<key::MockGrabber::Nice>())
321 , dbus_manager(std::make_shared<DBusManager>(session_manager))
322+ , systemd_wrapper(std::make_shared<SystemdWrapper>())
323 , upstart_wrapper(std::make_shared<UpstartWrapper>())
324 , shield_factory(std::make_shared<ShieldFactoryMock>())
325- , controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory)
326+ , controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory)
327 {}
328
329 struct ControllerWrap : Controller
330@@ -93,9 +94,10 @@
331 ControllerWrap(DBusManager::Ptr const& dbus_manager,
332 session::Manager::Ptr const& session_manager,
333 key::Grabber::Ptr const& key_grabber,
334+ SystemdWrapper::Ptr const& systemd_wrapper,
335 UpstartWrapper::Ptr const& upstart_wrapper,
336 ShieldFactoryInterface::Ptr const& shield_factory)
337- : Controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory, /* test_mode */ true)
338+ : Controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory, /* test_mode */ true)
339 {}
340
341 using Controller::shields_;
342@@ -112,6 +114,7 @@
343 session::MockManager::Ptr session_manager;
344 key::MockGrabber::Ptr key_grabber;
345 DBusManager::Ptr dbus_manager;
346+ unity::SystemdWrapper::Ptr systemd_wrapper;
347 unity::UpstartWrapper::Ptr upstart_wrapper;
348
349 ShieldFactoryMock::Ptr shield_factory;
350
351=== added file 'tests/test_systemd_wrapper.cpp'
352--- tests/test_systemd_wrapper.cpp 1970-01-01 00:00:00 +0000
353+++ tests/test_systemd_wrapper.cpp 2016-08-31 03:25:56 +0000
354@@ -0,0 +1,111 @@
355+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
356+/*
357+* Copyright (c) 2016 Canonical Ltd
358+*
359+* This program is free software: you can redistribute it and/or modify
360+* it under the terms of the GNU General Public License version 3 as
361+* published by the Free Software Foundation.
362+*
363+* This program is distributed in the hope that it will be useful,
364+* but WITHOUT ANY WARRANTY; without even the implied warranty of
365+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
366+* GNU General Public License for more details.
367+*
368+* You should have received a copy of the GNU General Public License
369+* along with this program. If not, see <http://www.gnu.org/licenses/>.
370+*
371+* Authored by: Ted Gould <ted@canonical.com>
372+*/
373+
374+#include <gtest/gtest.h>
375+using namespace testing;
376+
377+#include "unity-shared/SystemdWrapper.h"
378+
379+#include <UnityCore/GLibDBusServer.h>
380+#include <UnityCore/Variant.h>
381+
382+#include "test_utils.h"
383+
384+namespace
385+{
386+
387+const std::string SYSTEMD =
388+R"(<node>
389+ <interface name="org.freedesktop.systemd1.Manager">
390+ <method name="StartUnit">
391+ <arg name="name" type="s" direction="in" />
392+ <arg name="mode" type="s" direction="in" />
393+ <arg name="job" type="o" direction="out" />
394+ </method>
395+ <method name="StopUnit">
396+ <arg name="name" type="s" direction="in" />
397+ <arg name="mode" type="s" direction="in" />
398+ <arg name="job" type="o" direction="out" />
399+ </method>
400+ </interface>
401+</node>)";
402+
403+struct MockSystemdWrapper : unity::SystemdWrapper {
404+ MockSystemdWrapper()
405+ : SystemdWrapper(SystemdWrapper::TestMode())
406+ {}
407+};
408+
409+struct TestSystemdWrapper : public Test
410+{
411+ TestSystemdWrapper()
412+ {
413+ systemd_server_ = std::make_shared<unity::glib::DBusServer>("com.canonical.Unity.Test.Systemd");
414+ systemd_server_->AddObjects(SYSTEMD, "/org/freedesktop/systemd1");
415+
416+ Utils::WaitUntilMSec([this] { return systemd_server_->IsConnected(); });
417+ Utils::WaitUntilMSec([this] { return systemd_wrapper_.IsConnected(); });
418+ }
419+
420+ unity::glib::DBusServer::Ptr systemd_server_;
421+ MockSystemdWrapper systemd_wrapper_;
422+};
423+
424+
425+TEST_F(TestSystemdWrapper, Start)
426+{
427+ bool start_sent = false;
428+
429+ systemd_server_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant* par) -> GVariant* {
430+ if (method == "StartUnit")
431+ {
432+ start_sent = true;
433+
434+ std::string event_name = glib::Variant(g_variant_get_child_value(par, 0)).GetString();
435+ EXPECT_EQ("unity-screen-locked", event_name);
436+ }
437+
438+ return nullptr;
439+ });
440+
441+ systemd_wrapper_.Start("unity-screen-locked");
442+ Utils::WaitUntil(start_sent);
443+}
444+
445+TEST_F(TestSystemdWrapper, Stop)
446+{
447+ bool stop_sent = false;
448+
449+ systemd_server_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant* par) -> GVariant* {
450+ if (method == "StopUnit")
451+ {
452+ stop_sent = true;
453+
454+ std::string event_name = glib::Variant(g_variant_get_child_value(par, 0)).GetString();
455+ EXPECT_EQ("unity-screen-locked", event_name);
456+ }
457+
458+ return nullptr;
459+ });
460+
461+ systemd_wrapper_.Stop("unity-screen-locked");
462+ Utils::WaitUntil(stop_sent);
463+}
464+
465+}
466
467=== modified file 'tools/CMakeLists.txt'
468--- tools/CMakeLists.txt 2016-07-18 17:26:01 +0000
469+++ tools/CMakeLists.txt 2016-08-31 03:25:56 +0000
470@@ -28,3 +28,6 @@
471 add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_check.cpp)
472 target_link_libraries(unity-active-plugins-safety-check ${LIBS})
473 install(TARGETS unity-active-plugins-safety-check DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
474+
475+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity-compiz-profile-select.in ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select @ONLY)
476+install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
477
478=== added file 'tools/unity-compiz-profile-select.in'
479--- tools/unity-compiz-profile-select.in 1970-01-01 00:00:00 +0000
480+++ tools/unity-compiz-profile-select.in 2016-08-31 03:25:56 +0000
481@@ -0,0 +1,25 @@
482+#!/bin/bash
483+
484+set -e
485+
486+# If gnome-session is going to start compiz,
487+# we don't want to be the ones doing it.
488+
489+if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
490+ echo "GNOME Session is starting Compiz"
491+ stop ; exit 0
492+fi
493+
494+compiz_profile="ubuntu"
495+
496+if ! /usr/lib/nux/unity_support_test -p; then
497+ compiz_profile="ubuntu-lowgfx"
498+fi
499+
500+echo "Using compiz profile '$compiz_profile'"
501+
502+initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
503+systemctl set-environment --user COMPIZ_CONFIG_PROFILE="$compiz_profile"
504+
505+export COMPIZ_CONFIG_PROFILE="$compiz_profile"
506+exec @CMAKE_INSTALL_FULL_LIBDIR@/unity/unity-active-plugins-safety-check
507
508=== modified file 'unity-shared/CMakeLists.txt'
509--- unity-shared/CMakeLists.txt 2016-08-12 11:21:48 +0000
510+++ unity-shared/CMakeLists.txt 2016-08-31 03:25:56 +0000
511@@ -60,6 +60,7 @@
512 SpreadFilter.cpp
513 SpreadWidgets.cpp
514 StaticCairoText.cpp
515+ SystemdWrapper.cpp
516 TextureCache.cpp
517 TextInput.cpp
518 TextureThumbnailProvider.cpp
519
520=== added file 'unity-shared/SystemdWrapper.cpp'
521--- unity-shared/SystemdWrapper.cpp 1970-01-01 00:00:00 +0000
522+++ unity-shared/SystemdWrapper.cpp 2016-08-31 03:25:56 +0000
523@@ -0,0 +1,103 @@
524+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 3 -*-
525+/*
526+* Copyright © 2016 Canonical Ltd
527+*
528+* This program is free software: you can redistribute it and/or modify
529+* it under the terms of the GNU General Public License version 3 as
530+* published by the Free Software Foundation.
531+*
532+* This program is distributed in the hope that it will be useful,
533+* but WITHOUT ANY WARRANTY; without even the implied warranty of
534+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
535+* GNU General Public License for more details.
536+*
537+* You should have received a copy of the GNU General Public License
538+* along with this program. If not, see <http://www.gnu.org/licenses/>.
539+*
540+* Authored by: Ted Gould <ted@canonical.com>
541+*/
542+
543+#include "SystemdWrapper.h"
544+
545+#include <UnityCore/GLibDBusProxy.h>
546+
547+namespace unity
548+{
549+
550+//
551+// Start private implementation
552+//
553+
554+class SystemdWrapper::Impl
555+{
556+public:
557+ Impl(bool test);
558+
559+ void Start(std::string const& name);
560+ void Stop(std::string const& name);
561+ bool IsConnected();
562+
563+private:
564+ glib::DBusProxy::Ptr systemd_proxy_;
565+};
566+
567+SystemdWrapper::Impl::Impl(bool test)
568+{
569+ std::string busname = "org.freedesktop.systemd1";
570+ if (test) {
571+ busname = "com.canonical.Unity.Test.Systemd";
572+ }
573+
574+ systemd_proxy_ = std::make_shared<unity::glib::DBusProxy>(busname, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager");
575+}
576+
577+void SystemdWrapper::Impl::Start(std::string const& name)
578+{
579+ if (IsConnected()) {
580+ systemd_proxy_->Call("StartUnit", g_variant_new("(ss)", name.c_str(), "replace"));
581+ }
582+}
583+
584+void SystemdWrapper::Impl::Stop(std::string const& name)
585+{
586+ if (IsConnected()) {
587+ systemd_proxy_->Call("StopUnit", g_variant_new("(ss)", name.c_str(), "replace"));
588+ }
589+}
590+
591+bool SystemdWrapper::Impl::IsConnected()
592+{
593+ return systemd_proxy_->IsConnected();
594+}
595+
596+//
597+// End private implementation
598+//
599+
600+SystemdWrapper::SystemdWrapper()
601+ : pimpl_(new Impl(false))
602+{}
603+
604+SystemdWrapper::SystemdWrapper(SystemdWrapper::TestMode const& tm)
605+ : pimpl_(new Impl(true))
606+{}
607+
608+SystemdWrapper::~SystemdWrapper()
609+{}
610+
611+void SystemdWrapper::Start(std::string const& name)
612+{
613+ pimpl_->Start(name);
614+}
615+
616+void SystemdWrapper::Stop(std::string const& name)
617+{
618+ pimpl_->Stop(name);
619+}
620+
621+bool SystemdWrapper::IsConnected()
622+{
623+ return pimpl_->IsConnected();
624+}
625+
626+}
627
628=== added file 'unity-shared/SystemdWrapper.h'
629--- unity-shared/SystemdWrapper.h 1970-01-01 00:00:00 +0000
630+++ unity-shared/SystemdWrapper.h 2016-08-31 03:25:56 +0000
631@@ -0,0 +1,55 @@
632+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
633+/*
634+* Copyright © 2016 Canonical Ltd
635+*
636+* This program is free software: you can redistribute it and/or modify
637+* it under the terms of the GNU General Public License version 3 as
638+* published by the Free Software Foundation.
639+*
640+* This program is distributed in the hope that it will be useful,
641+* but WITHOUT ANY WARRANTY; without even the implied warranty of
642+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643+* GNU General Public License for more details.
644+*
645+* You should have received a copy of the GNU General Public License
646+* along with this program. If not, see <http://www.gnu.org/licenses/>.
647+*
648+* Authored by: Ted Gould <ted@canonical.com>
649+*/
650+
651+#ifndef UNITY_SYSTEMD_WRAPPER
652+#define UNITY_SYSTEMD_WRAPPER
653+
654+#include <memory>
655+
656+namespace unity
657+{
658+
659+class SystemdWrapper
660+{
661+public:
662+ typedef std::shared_ptr<SystemdWrapper> Ptr;
663+
664+ SystemdWrapper();
665+ ~SystemdWrapper();
666+
667+ void Start(std::string const& name);
668+ void Stop(std::string const& name);
669+ bool IsConnected();
670+
671+protected:
672+ struct TestMode {};
673+ SystemdWrapper(TestMode const&);
674+
675+private:
676+ // Noncopyable
677+ SystemdWrapper(SystemdWrapper const&) = delete;
678+ SystemdWrapper& operator=(SystemdWrapper const&) = delete;
679+
680+ class Impl;
681+ std::unique_ptr<Impl> pimpl_;
682+};
683+
684+}
685+
686+#endif
687
688=== modified file 'unity7.conf.in'
689--- unity7.conf.in 2016-07-21 13:01:59 +0000
690+++ unity7.conf.in 2016-08-31 03:25:56 +0000
691@@ -4,27 +4,7 @@
692 start on xsession SESSION=ubuntu and started unity-settings-daemon
693 stop on desktop-end
694
695-pre-start script
696- # If gnome-session is going to start compiz,
697- # we don't want to be the ones doing it.
698-
699- if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
700- echo "GNOME Session is starting Compiz"
701- stop ; exit 0
702- fi
703-
704- compiz_profile="ubuntu"
705-
706- if ! /usr/lib/nux/unity_support_test -p; then
707- compiz_profile="ubuntu-lowgfx"
708- fi
709-
710- echo "Using compiz profile '$compiz_profile'"
711- initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
712- export COMPIZ_CONFIG_PROFILE="$compiz_profile"
713-
714- ${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-active-plugins-safety-check
715-end script
716+pre-start exec @CMAKE_INSTALL_FULL_LIBDIR@/unity-compiz-profile-select
717
718 respawn
719 exec compiz
720
721=== added file 'unity7.override'
722--- unity7.override 1970-01-01 00:00:00 +0000
723+++ unity7.override 2016-08-31 03:25:56 +0000
724@@ -0,0 +1,1 @@
725+manual
726
727=== added file 'unity7.service.in'
728--- unity7.service.in 1970-01-01 00:00:00 +0000
729+++ unity7.service.in 2016-08-31 03:25:56 +0000
730@@ -0,0 +1,11 @@
731+[Unit]
732+Description=Unity Shell v7
733+Requires=unity-settings-daemon.service unity-panel-service.service bamfdaemon.service
734+Wants=unity-gtk-module.service
735+After=unity-settings-daemon.service
736+PartOf=graphical-session.target
737+
738+[Service]
739+ExecStart=/usr/bin/compiz
740+ExecStartPre=@CMAKE_INSTALL_FULL_LIBDIR@/unity-compiz-profile-select
741+Restart=on-failure