summaryrefslogtreecommitdiff
path: root/tools
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2016-09-05 12:46:49 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2016-09-05 12:46:49 +0200
commita6a2105717a9f27799f9f3de429e4bd9da82c6cc (patch)
tree07d8a98c2b80c2ef834822710382daed24b6039d /tools
parentc43a2ce890e5ae29a915430d787c303c7a0420d9 (diff)
Tools: add systemd/upstart pre-start scripts
(bzr r4153.9.56)
Diffstat (limited to 'tools')
-rw-r--r--tools/CMakeLists.txt7
-rwxr-xr-xtools/compiz-profile-selector.in (renamed from tools/unity-compiz-profile-select.in)13
-rw-r--r--tools/systemd-prestart-check23
-rw-r--r--tools/upstart-prestart-check17
4 files changed, 49 insertions, 11 deletions
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 4fbc611c8..a9a5bc283 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -29,5 +29,8 @@ add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_che
target_link_libraries(unity-active-plugins-safety-check ${LIBS})
install(TARGETS unity-active-plugins-safety-check DESTINATION ${UNITY_INSTALL_LIBDIR})
-configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity-compiz-profile-select.in ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select @ONLY)
-install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/unity-compiz-profile-select DESTINATION ${UNITY_INSTALL_LIBDIR})
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/compiz-profile-selector.in ${CMAKE_CURRENT_BINARY_DIR}/compiz-profile-selector @ONLY)
+install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/compiz-profile-selector DESTINATION ${UNITY_INSTALL_LIBDIR})
+
+install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/systemd-prestart-check DESTINATION ${UNITY_INSTALL_LIBDIR})
+install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/upstart-prestart-check DESTINATION ${UNITY_INSTALL_LIBDIR})
diff --git a/tools/unity-compiz-profile-select.in b/tools/compiz-profile-selector.in
index 85da5dd71..8041f109b 100755
--- a/tools/unity-compiz-profile-select.in
+++ b/tools/compiz-profile-selector.in
@@ -1,14 +1,6 @@
#!/bin/bash
set -e
-
-# If gnome-session is going to start compiz,
-# we don't want to be the ones doing it.
-if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
- echo "GNOME Session is starting Compiz"
- stop ; exit 0
-fi
-
compiz_profile="ubuntu"
if ! /usr/lib/nux/unity_support_test -p; then
@@ -17,7 +9,10 @@ fi
echo "Using compiz profile '$compiz_profile'"
-initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
+if [ -n "$UPSTART_SESSION" ]; then
+ initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
+fi
+
dbus-update-activation-environment --verbose --systemd COMPIZ_CONFIG_PROFILE="$compiz_profile"
export COMPIZ_CONFIG_PROFILE="$compiz_profile"
diff --git a/tools/systemd-prestart-check b/tools/systemd-prestart-check
new file mode 100644
index 000000000..8608da10f
--- /dev/null
+++ b/tools/systemd-prestart-check
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -e
+
+# If gnome-session is going to start compiz,
+# we don't want to be the ones doing it.
+if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
+ echo "GNOME Session is starting Compiz"
+ exit 1
+fi
+
+if [ -z "$UPSTART_SESSION" ]; then
+ exit 0
+fi
+
+status=$(initctl status unity7) || true
+
+if (echo "$status" | grep -q "start/running"); then
+ echo "Unity is managed by Upstart"
+ exit 1
+fi
+
+exit 0
diff --git a/tools/upstart-prestart-check b/tools/upstart-prestart-check
new file mode 100644
index 000000000..f6637dc44
--- /dev/null
+++ b/tools/upstart-prestart-check
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+set -e
+
+# If gnome-session is going to start compiz,
+# we don't want to be the ones doing it.
+if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
+ echo "GNOME Session is starting Compiz"
+ stop
+ exit 0
+fi
+
+if (systemctl --user is-active unity7); then
+ echo "Unity instance is managed by Systemd, ignoring request..."
+ stop
+ exit 0
+fi