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

Proposed by Ted Gould
Status: Superseded
Proposed branch: lp:~ted/unity/systemd-unit.
Merge into: lp:unity
Diff against target: 604 lines (+360/-20)
22 files modified
debian/control (+2/-0)
debian/libunity-core-6.0-9.install (+2/-0)
debian/unity-services.install (+1/-0)
debian/unity7.conf (+1/-18)
debian/unity7.override (+1/-0)
debian/unity7.service (+11/-0)
lockscreen/LockScreenController.cpp (+4/-0)
lockscreen/LockScreenController.h (+3/-0)
plugins/unityshell/unityshell.xml.in (+2/-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/test_lockscreen_controller.cpp (+5/-2)
tools/CMakeLists.txt (+24/-0)
tools/unity-compiz-profile (+25/-0)
tools/unity_active_plugins_safety_check.cpp (+83/-0)
unity-shared/CMakeLists.txt (+1/-0)
unity-shared/SystemdWrapper.cpp (+88/-0)
unity-shared/SystemdWrapper.h (+54/-0)
To merge this branch: bzr merge lp:~ted/unity/systemd-unit.
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+300584@code.launchpad.net

This proposal has been superseded by a proposal from 2016-07-20.

Commit message

Adding systemd user session units

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2016-03-21 15:38:17 +0000
+++ debian/control 2016-07-20 15:08:18 +0000
@@ -52,6 +52,7 @@
52 python3 (>= 3.4),52 python3 (>= 3.4),
53 python-setuptools,53 python-setuptools,
54 quilt,54 quilt,
55 systemd,
55 xserver-xorg-video-dummy,56 xserver-xorg-video-dummy,
56 xsltproc,57 xsltproc,
57Standards-Version: 3.9.558Standards-Version: 3.9.5
@@ -127,6 +128,7 @@
127Architecture: all128Architecture: all
128Multi-Arch: foreign129Multi-Arch: foreign
129Depends: ${misc:Depends},130Depends: ${misc:Depends},
131 indicator-common,
130Replaces: libunity-core-6.0-9 (<< 7.3.0),132Replaces: libunity-core-6.0-9 (<< 7.3.0),
131Breaks: libunity-core-6.0-9 (<< 7.3.0),133Breaks: libunity-core-6.0-9 (<< 7.3.0),
132Description: Interface designed for efficiency of space and interaction.134Description: Interface designed for efficiency of space and interaction.
133135
=== modified file 'debian/libunity-core-6.0-9.install'
--- debian/libunity-core-6.0-9.install 2016-02-09 01:26:22 +0000
+++ debian/libunity-core-6.0-9.install 2016-07-20 15:08:18 +0000
@@ -6,4 +6,6 @@
6debian/unity-crashdb.conf etc/apport/crashdb.conf.d/6debian/unity-crashdb.conf etc/apport/crashdb.conf.d/
7debian/source_unity.py usr/share/apport/package-hooks7debian/source_unity.py usr/share/apport/package-hooks
8debian/unity7.conf usr/share/upstart/sessions8debian/unity7.conf usr/share/upstart/sessions
9debian/unity7.service usr/lib/systemd/user
10debian/unity7.override usr/share/upstart/systemd-session/upstart
9tools/convert-files/* usr/lib/compiz/migration/11tools/convert-files/* usr/lib/compiz/migration/
1012
=== modified file 'debian/unity-services.install'
--- debian/unity-services.install 2016-02-09 01:26:22 +0000
+++ debian/unity-services.install 2016-07-20 15:08:18 +0000
@@ -1,3 +1,4 @@
1usr/lib/*/unity/*service1usr/lib/*/unity/*service
2usr/share/upstart2usr/share/upstart
3usr/lib/systemd
3usr/share/man/*/unity-panel-service.14usr/share/man/*/unity-panel-service.1
45
=== modified file 'debian/unity7.conf'
--- debian/unity7.conf 2016-07-05 01:26:04 +0000
+++ debian/unity7.conf 2016-07-20 15:08:18 +0000
@@ -4,24 +4,7 @@
4start on xsession SESSION=ubuntu and started unity-settings-daemon4start on xsession SESSION=ubuntu and started unity-settings-daemon
5stop on desktop-end5stop on desktop-end
66
7pre-start script7pre-start exec /usr/lib/unity/unity-compiz-profile
8 # If gnome-session is going to start compiz,
9 # we don't want to be the ones doing it.
10
11 if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
12 echo "GNOME Session is starting Compiz"
13 stop ; exit 0
14 fi
15
16 compiz_profile="ubuntu"
17
18 if ! /usr/lib/nux/unity_support_test -p; then
19 compiz_profile="ubuntu-lowgfx"
20 fi
21
22 echo "Using compiz profile '$compiz_profile'"
23 initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
24end script
258
26respawn9respawn
27exec compiz10exec compiz
2811
=== added file 'debian/unity7.override'
--- debian/unity7.override 1970-01-01 00:00:00 +0000
+++ debian/unity7.override 2016-07-20 15:08:18 +0000
@@ -0,0 +1,1 @@
1manual
02
=== added file 'debian/unity7.service'
--- debian/unity7.service 1970-01-01 00:00:00 +0000
+++ debian/unity7.service 2016-07-20 15:08:18 +0000
@@ -0,0 +1,11 @@
1[Unit]
2Description=Unity Shell v7
3Requires=unity-settings-daemon.service unity-panel-service.service bamfdaemon.service
4Wants=unity-gtk-module.service
5After=unity-settings-daemon.service
6PartOf=graphical-session.target
7
8[Service]
9ExecStart=/usr/bin/compiz
10ExecStart.Pre=/usr/lib/unity/unity-compiz-profile
11Restart=on-failure
012
=== modified file 'lockscreen/LockScreenController.cpp'
--- lockscreen/LockScreenController.cpp 2016-07-04 12:45:06 +0000
+++ lockscreen/LockScreenController.cpp 2016-07-20 15:08:18 +0000
@@ -56,6 +56,7 @@
56Controller::Controller(DBusManager::Ptr const& dbus_manager,56Controller::Controller(DBusManager::Ptr const& dbus_manager,
57 session::Manager::Ptr const& session_manager,57 session::Manager::Ptr const& session_manager,
58 key::Grabber::Ptr const& key_grabber,58 key::Grabber::Ptr const& key_grabber,
59 SystemdWrapper::Ptr const& systemd_wrapper,
59 UpstartWrapper::Ptr const& upstart_wrapper,60 UpstartWrapper::Ptr const& upstart_wrapper,
60 ShieldFactoryInterface::Ptr const& shield_factory,61 ShieldFactoryInterface::Ptr const& shield_factory,
61 bool test_mode)62 bool test_mode)
@@ -63,6 +64,7 @@
63 , dbus_manager_(dbus_manager)64 , dbus_manager_(dbus_manager)
64 , session_manager_(session_manager)65 , session_manager_(session_manager)
65 , key_grabber_(key_grabber)66 , key_grabber_(key_grabber)
67 , systemd_wrapper_(systemd_wrapper)
66 , upstart_wrapper_(upstart_wrapper)68 , upstart_wrapper_(upstart_wrapper)
67 , shield_factory_(shield_factory)69 , shield_factory_(shield_factory)
68 , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>())70 , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>())
@@ -129,6 +131,7 @@
129 shields_.clear();131 shields_.clear();
130132
131 upstart_wrapper_->Emit("desktop-unlock");133 upstart_wrapper_->Emit("desktop-unlock");
134 systemd_wrapper_->Stop("unity-screen-locked.target");
132 accelerator_controller_.reset();135 accelerator_controller_.reset();
133 indicators_.reset();136 indicators_.reset();
134 }137 }
@@ -464,6 +467,7 @@
464{467{
465 indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();468 indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();
466 upstart_wrapper_->Emit("desktop-lock");469 upstart_wrapper_->Emit("desktop-lock");
470 systemd_wrapper_->Stop("unity-screen-locked.target");
467471
468 accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_);472 accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_);
469 auto activate_key = WindowManager::Default().activate_indicators_key();473 auto activate_key = WindowManager::Default().activate_indicators_key();
470474
=== modified file 'lockscreen/LockScreenController.h'
--- lockscreen/LockScreenController.h 2016-06-21 01:28:26 +0000
+++ lockscreen/LockScreenController.h 2016-07-20 15:08:18 +0000
@@ -31,6 +31,7 @@
31#include "ScreenSaverDBusManager.h"31#include "ScreenSaverDBusManager.h"
32#include "unity-shared/BackgroundEffectHelper.h"32#include "unity-shared/BackgroundEffectHelper.h"
33#include "unity-shared/KeyGrabber.h"33#include "unity-shared/KeyGrabber.h"
34#include "unity-shared/SystemdWrapper.h"
34#include "unity-shared/UpstartWrapper.h"35#include "unity-shared/UpstartWrapper.h"
3536
36namespace unity37namespace unity
@@ -46,6 +47,7 @@
46 typedef std::shared_ptr<Controller> Ptr;47 typedef std::shared_ptr<Controller> Ptr;
4748
48 Controller(DBusManager::Ptr const&, session::Manager::Ptr const&, key::Grabber::Ptr const&,49 Controller(DBusManager::Ptr const&, session::Manager::Ptr const&, key::Grabber::Ptr const&,
50 SystemdWrapper::Ptr const& systemd_wrapper = std::make_shared<SystemdWrapper>(),
49 UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(),51 UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(),
50 ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(),52 ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(),
51 bool test_mode = false);53 bool test_mode = false);
@@ -88,6 +90,7 @@
88 key::Grabber::Ptr key_grabber_;90 key::Grabber::Ptr key_grabber_;
89 indicator::Indicators::Ptr indicators_;91 indicator::Indicators::Ptr indicators_;
90 AcceleratorController::Ptr accelerator_controller_;92 AcceleratorController::Ptr accelerator_controller_;
93 SystemdWrapper::Ptr systemd_wrapper_;
91 UpstartWrapper::Ptr upstart_wrapper_;94 UpstartWrapper::Ptr upstart_wrapper_;
92 ShieldFactoryInterface::Ptr shield_factory_;95 ShieldFactoryInterface::Ptr shield_factory_;
93 SuspendInhibitorManager::Ptr suspend_inhibitor_manager_;96 SuspendInhibitorManager::Ptr suspend_inhibitor_manager_;
9497
=== modified file 'plugins/unityshell/unityshell.xml.in'
--- plugins/unityshell/unityshell.xml.in 2016-04-05 13:23:27 +0000
+++ plugins/unityshell/unityshell.xml.in 2016-07-20 15:08:18 +0000
@@ -39,6 +39,8 @@
39 <plugin>compiztoolbox</plugin>39 <plugin>compiztoolbox</plugin>
40 <plugin>scale</plugin>40 <plugin>scale</plugin>
41 <plugin>expo</plugin>41 <plugin>expo</plugin>
42 <plugin>move</plugin>
43 <plugin>resize</plugin>
42 </requirement>44 </requirement>
43 <conflict>45 <conflict>
44 <plugin>decor</plugin>46 <plugin>decor</plugin>
4547
=== modified file 'services/CMakeLists.txt'
--- services/CMakeLists.txt 2016-02-09 01:26:22 +0000
+++ services/CMakeLists.txt 2016-07-20 15:08:18 +0000
@@ -58,3 +58,34 @@
5858
59configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf)59configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf)
60install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)60install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
61
62##
63## Systemd Unit Files
64##
65
66# where to install
67# Uncomment when we drop Vivid
68# pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
69set (SYSTEMD_USER_DIR "/usr/lib/systemd/user")
70message (STATUS "${SYSTEMD_USER_DIR} is the systemd user unit file install dir")
71
72configure_file (unity-panel-service.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service")
73configure_file (unity-panel-service-lockscreen.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service")
74
75install( FILES
76 "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service"
77 "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service"
78 "${CMAKE_CURRENT_BINARY_DIR}/unity-screen-locked.target"
79 DESTINATION "${SYSTEMD_USER_DIR}")
80
81##
82## Upstart systemd override Job File
83##
84
85set (UPSTART_SYSTEMD_OVERRIDE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/upstart/systemd-session/upstart")
86message (STATUS "${UPSTART_SYSTEMD_OVERRIDE_DIR} is the Upstart override Job File for systemd dir")
87
88install (FILES
89 unity-panel-service.override
90 unity-panel-service-lockscreen.override
91 DESTINATION "${UPSTART_SYSTEMD_OVERRIDE_DIR}")
6192
=== added file 'services/unity-panel-service-lockscreen.override'
--- services/unity-panel-service-lockscreen.override 1970-01-01 00:00:00 +0000
+++ services/unity-panel-service-lockscreen.override 2016-07-20 15:08:18 +0000
@@ -0,0 +1,1 @@
1manual
02
=== added file 'services/unity-panel-service-lockscreen.service.in'
--- services/unity-panel-service-lockscreen.service.in 1970-01-01 00:00:00 +0000
+++ services/unity-panel-service-lockscreen.service.in 2016-07-20 15:08:18 +0000
@@ -0,0 +1,7 @@
1[Unit]
2Description=Backing Service for the Unity Panel in Lockscreen mode
3PartOf=unity-screen-locked.target
4
5[Service]
6ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service --lockscreen-mode
7Restart=on-failure
08
=== added file 'services/unity-panel-service.override'
--- services/unity-panel-service.override 1970-01-01 00:00:00 +0000
+++ services/unity-panel-service.override 2016-07-20 15:08:18 +0000
@@ -0,0 +1,1 @@
1manual
02
=== added file 'services/unity-panel-service.service.in'
--- services/unity-panel-service.service.in 1970-01-01 00:00:00 +0000
+++ services/unity-panel-service.service.in 2016-07-20 15:08:18 +0000
@@ -0,0 +1,9 @@
1[Unit]
2Description=Backing Service for the Unity Panel
3After=unity7.service
4PartOf=graphical-session.target
5BindsTo=indicators-pre.target
6
7[Service]
8ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service
9Restart=on-failure
010
=== added file 'services/unity-screen-locked.target'
--- services/unity-screen-locked.target 1970-01-01 00:00:00 +0000
+++ services/unity-screen-locked.target 2016-07-20 15:08:18 +0000
@@ -0,0 +1,4 @@
1[Unit]
2Description=A target that, when running, represents the screen being locked
3Wants=ubuntu-panel-service-lock.service
4PartOf=graphical-session.target
05
=== modified file 'tests/test_lockscreen_controller.cpp'
--- tests/test_lockscreen_controller.cpp 2016-06-21 14:40:26 +0000
+++ tests/test_lockscreen_controller.cpp 2016-07-20 15:08:18 +0000
@@ -83,9 +83,10 @@
83 , session_manager(std::make_shared<NiceMock<session::MockManager>>())83 , session_manager(std::make_shared<NiceMock<session::MockManager>>())
84 , key_grabber(std::make_shared<key::MockGrabber::Nice>())84 , key_grabber(std::make_shared<key::MockGrabber::Nice>())
85 , dbus_manager(std::make_shared<DBusManager>(session_manager))85 , dbus_manager(std::make_shared<DBusManager>(session_manager))
86 , systemd_wrapper(std::make_shared<SystemdWrapper>())
86 , upstart_wrapper(std::make_shared<UpstartWrapper>())87 , upstart_wrapper(std::make_shared<UpstartWrapper>())
87 , shield_factory(std::make_shared<ShieldFactoryMock>())88 , shield_factory(std::make_shared<ShieldFactoryMock>())
88 , controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory)89 , controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory)
89 {}90 {}
9091
91 struct ControllerWrap : Controller92 struct ControllerWrap : Controller
@@ -93,9 +94,10 @@
93 ControllerWrap(DBusManager::Ptr const& dbus_manager,94 ControllerWrap(DBusManager::Ptr const& dbus_manager,
94 session::Manager::Ptr const& session_manager,95 session::Manager::Ptr const& session_manager,
95 key::Grabber::Ptr const& key_grabber,96 key::Grabber::Ptr const& key_grabber,
97 SystemdWrapper::Ptr const& systemd_wrapper,
96 UpstartWrapper::Ptr const& upstart_wrapper,98 UpstartWrapper::Ptr const& upstart_wrapper,
97 ShieldFactoryInterface::Ptr const& shield_factory)99 ShieldFactoryInterface::Ptr const& shield_factory)
98 : Controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory, /* test_mode */ true)100 : Controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory, /* test_mode */ true)
99 {}101 {}
100102
101 using Controller::shields_;103 using Controller::shields_;
@@ -112,6 +114,7 @@
112 session::MockManager::Ptr session_manager;114 session::MockManager::Ptr session_manager;
113 key::MockGrabber::Ptr key_grabber;115 key::MockGrabber::Ptr key_grabber;
114 DBusManager::Ptr dbus_manager;116 DBusManager::Ptr dbus_manager;
117 unity::SystemdWrapper::Ptr systemd_wrapper;
115 unity::UpstartWrapper::Ptr upstart_wrapper;118 unity::UpstartWrapper::Ptr upstart_wrapper;
116119
117 ShieldFactoryMock::Ptr shield_factory;120 ShieldFactoryMock::Ptr shield_factory;
118121
=== modified file 'tools/CMakeLists.txt'
--- tools/CMakeLists.txt 2016-02-09 01:26:22 +0000
+++ tools/CMakeLists.txt 2016-07-20 15:08:18 +0000
@@ -6,3 +6,27 @@
6configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity.cmake ${CMAKE_BINARY_DIR}/bin/unity)6configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity.cmake ${CMAKE_BINARY_DIR}/bin/unity)
7install(FILES ${CMAKE_BINARY_DIR}/bin/unity PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ7install(FILES ${CMAKE_BINARY_DIR}/bin/unity PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
8GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION ${CMAKE_INSTALL_BINDIR})8GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION ${CMAKE_INSTALL_BINDIR})
9
10#
11# unity-active-plugins-safety-check
12#
13pkg_check_modules(UAPSC_DEPS REQUIRED libcompizconfig)
14
15set(CFLAGS
16 ${UAPSC_DEPS_CFLAGS}
17 ${UAPSC_DEPS_CFLAGS_OTHER}
18 )
19
20string (REPLACE ";" " " CFLAGS "${CFLAGS}")
21set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFLAGS}")
22
23set(LIBS ${UAPSC_DEPS_LIBRARIES})
24
25set(LIB_PATHS ${UAPSC_DEPS_LIBRARY_DIRS})
26link_directories(${LIB_PATHS})
27
28add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_check.cpp)
29target_link_libraries(unity-active-plugins-safety-check ${LIBS})
30install(TARGETS unity-active-plugins-safety-check DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
31
32install(FILES unity-compiz-profile DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
933
=== added file 'tools/unity-compiz-profile'
--- tools/unity-compiz-profile 1970-01-01 00:00:00 +0000
+++ tools/unity-compiz-profile 2016-07-20 15:08:18 +0000
@@ -0,0 +1,25 @@
1#!/bin/bash
2
3set -e
4
5# If gnome-session is going to start compiz,
6# we don't want to be the ones doing it.
7
8if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
9 echo "GNOME Session is starting Compiz"
10 stop ; exit 0
11fi
12
13compiz_profile="ubuntu"
14
15if ! /usr/lib/nux/unity_support_test -p; then
16 compiz_profile="ubuntu-lowgfx"
17fi
18
19echo "Using compiz profile '$compiz_profile'"
20
21initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
22systemctl set-environment --user COMPIZ_CONFIG_PROFILE="$compiz_profile"
23
24export COMPIZ_CONFIG_PROFILE="$compiz_profile"
25exec /usr/lib/unity/unity-active-plugins-safety-check
026
=== added file 'tools/unity_active_plugins_safety_check.cpp'
--- tools/unity_active_plugins_safety_check.cpp 1970-01-01 00:00:00 +0000
+++ tools/unity_active_plugins_safety_check.cpp 2016-07-20 15:08:18 +0000
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
17 */
18
19#include <ccs.h>
20#include <gio/gio.h>
21
22#include <iostream>
23#include <string>
24
25extern const CCSInterfaceTable ccsDefaultInterfaceTable;
26
27void PluginSetActiveWithDeps(CCSContext* context, std::string const& plugin_name)
28{
29 if (plugin_name.empty())
30 return;
31
32 auto plugin = ccsFindPlugin(context, plugin_name.c_str());
33
34 if (!plugin)
35 return;
36
37 auto reqs = ccsPluginGetRequiresPlugins(plugin);
38 for (auto req = reqs; req; req = req->next)
39 {
40 if (req->data && req->data->value)
41 {
42 std::string name = req->data->value;
43 PluginSetActiveWithDeps(context, name.c_str());
44 }
45 }
46
47 if (!ccsPluginIsActive(context, plugin_name.c_str())) {
48 std::cout << "Setting plugin '" << plugin_name << "' to active" << std::endl;
49 ccsPluginSetActive(plugin, true);
50 }
51
52 auto conflicts = ccsPluginGetConflictPlugins(plugin);
53 for (auto con = conflicts; con; con = con->next)
54 {
55 if (con->data && con->data->value)
56 {
57 std::string name = con->data->value;
58 auto plugin = ccsFindPlugin(context, name.c_str());
59
60 if (ccsPluginIsActive(context, name.c_str()))
61 {
62 std::cout << "Setting plugin '" << name << "' to non-active" << std::endl;
63 ccsPluginSetActive(plugin, false);
64 }
65 }
66 }
67}
68
69int main()
70{
71 auto context = ccsContextNew (0, &ccsDefaultInterfaceTable);
72
73 if (!context)
74 return -1;
75
76 PluginSetActiveWithDeps(context, "unityshell");
77
78 ccsWriteChangedSettings(context);
79 g_settings_sync();
80 ccsFreeContext(context);
81
82 return 0;
83}
084
=== modified file 'unity-shared/CMakeLists.txt'
--- unity-shared/CMakeLists.txt 2016-02-25 15:59:41 +0000
+++ unity-shared/CMakeLists.txt 2016-07-20 15:08:18 +0000
@@ -59,6 +59,7 @@
59 SearchBarSpinner.cpp59 SearchBarSpinner.cpp
60 SpreadFilter.cpp60 SpreadFilter.cpp
61 StaticCairoText.cpp61 StaticCairoText.cpp
62 SystemdWrapper.cpp
62 TextureCache.cpp63 TextureCache.cpp
63 TextInput.cpp64 TextInput.cpp
64 TextureThumbnailProvider.cpp65 TextureThumbnailProvider.cpp
6566
=== added file 'unity-shared/SystemdWrapper.cpp'
--- unity-shared/SystemdWrapper.cpp 1970-01-01 00:00:00 +0000
+++ unity-shared/SystemdWrapper.cpp 2016-07-20 15:08:18 +0000
@@ -0,0 +1,88 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 3 -*-
2/*
3* Copyright © 2016 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Ted Gould <ted@canonical.com>
18*/
19
20#include "SystemdWrapper.h"
21
22#include <UnityCore/GLibDBusProxy.h>
23
24namespace unity
25{
26
27//
28// Start private implementation
29//
30
31class SystemdWrapper::Impl
32{
33public:
34 Impl();
35
36 void Start(std::string const& name);
37 void Stop(std::string const& name);
38
39private:
40 glib::DBusProxy::Ptr systemd_proxy_;
41};
42
43SystemdWrapper::Impl::Impl()
44{
45 std::string busname = "org.freedesktop.systemd1";
46 if (g_getenv("UNITY_TEST_SYSTEMD)")) {
47 busname = "com.canonical.Unity.Test.Systemd";
48 }
49
50 systemd_proxy_ = std::make_shared<unity::glib::DBusProxy>(busname, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager");
51}
52
53void SystemdWrapper::Impl::Start(std::string const& name)
54{
55 systemd_proxy_->Call("StartUnit", g_variant_new("(ss)", name.c_str(), "replace"));
56}
57
58void SystemdWrapper::Impl::Stop(std::string const& name)
59{
60 systemd_proxy_->Call("StopUnit", g_variant_new("(ss)", name.c_str(), "replace"));
61}
62
63//
64// End private implementation
65//
66
67SystemdWrapper::SystemdWrapper()
68 : pimpl_(new Impl)
69{}
70
71SystemdWrapper::SystemdWrapper(SystemdWrapper::TestMode const& tm)
72 : pimpl_(new Impl)
73{}
74
75SystemdWrapper::~SystemdWrapper()
76{}
77
78void SystemdWrapper::Start(std::string const& name)
79{
80 pimpl_->Start(name);
81}
82
83void SystemdWrapper::Stop(std::string const& name)
84{
85 pimpl_->Stop(name);
86}
87
88}
089
=== added file 'unity-shared/SystemdWrapper.h'
--- unity-shared/SystemdWrapper.h 1970-01-01 00:00:00 +0000
+++ unity-shared/SystemdWrapper.h 2016-07-20 15:08:18 +0000
@@ -0,0 +1,54 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright © 2016 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Ted Gould <ted@canonical.com>
18*/
19
20#ifndef UNITY_SYSTEMD_WRAPPER
21#define UNITY_SYSTEMD_WRAPPER
22
23#include <memory>
24
25namespace unity
26{
27
28class SystemdWrapper
29{
30public:
31 typedef std::shared_ptr<SystemdWrapper> Ptr;
32
33 SystemdWrapper();
34 ~SystemdWrapper();
35
36 void Start(std::string const& name);
37 void Stop(std::string const& name);
38
39protected:
40 struct TestMode {};
41 SystemdWrapper(TestMode const&);
42
43private:
44 // Noncopyable
45 SystemdWrapper(SystemdWrapper const&) = delete;
46 SystemdWrapper& operator=(SystemdWrapper const&) = delete;
47
48 class Impl;
49 std::unique_ptr<Impl> pimpl_;
50};
51
52}
53
54#endif