Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make systemd dependency optional #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include(CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)

# Options
option(ENABLE_SYSTEMD "Enables systemd support" OFF)
option(ENABLE_SYSTEMD "Enables systemd support" ON)
option(ENABLE_ALSA "Enables Alsa mixer backend" ON)
option(ENABLE_PULSEAUDIO "Enables PulseAudio mixer backend" ON)
option(ENABLE_NETWORK_MANAGER "Enables network indicator based on NetworkManager" ON)
Expand All @@ -38,11 +38,13 @@ include(KDECMakeSettings)
find_package(PkgConfig)

# systemd user unit directory
if (ENABLE_SYSTEMD)
if (NOT DEFINED SYSTEMD_USER_UNIT_DIR)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=systemduserunitdir systemd OUTPUT_VARIABLE SYSTEMD_USER_UNIT_DIR)
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_USER_UNIT_DIR ${SYSTEMD_USER_UNIT_DIR})
endif()
message(STATUS "systemd user unit directory: ${SYSTEMD_USER_UNIT_DIR}")
endif()

# Require at least gcc 4.8
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Expand Down Expand Up @@ -74,7 +76,7 @@ endif()

# Assume release build by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
endif()

# Minimum version requirements
Expand Down Expand Up @@ -148,3 +150,4 @@ greenisland_install_shell(org.hawaiios.desktop shell)

# Display featute summary
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)

21 changes: 21 additions & 0 deletions compositor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/3rdparty
)

if( ENABLE_SYSTEMD)
set(SOURCES
application.cpp
main.cpp
Expand All @@ -27,6 +28,26 @@ set(SOURCES
session/authenticator.cpp
session/sessioninterface.cpp
)
else()
set(SOURCES
application.cpp
main.cpp
processlauncher.cpp
screensaver.cpp
sessionmanager.cpp
loginmanager/loginmanager.cpp
loginmanager/loginmanagerbackend.cpp
loginmanager/fakebackend.cpp
powermanager/powermanager.cpp
powermanager/powermanager.h
powermanager/powermanagerbackend.cpp
powermanager/powermanagerbackend.h
powermanager/upowerpowerbackend.cpp
powermanager/upowerpowerbackend.h
session/authenticator.cpp
session/sessioninterface.cpp
)
endif()

qt5_add_dbus_adaptor(SOURCES org.hawaiios.ProcessLauncher.xml
processlauncher.h ProcessLauncher
Expand Down
5 changes: 4 additions & 1 deletion compositor/loginmanager/loginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@

#include "fakebackend.h"
#include "loginmanager.h"
#ifdef ENABLE_SYSTEMD
#include "logindbackend.h"

#endif
Q_LOGGING_CATEGORY(LOGINMANAGER, "hawaii.loginmanager")

LoginManager::LoginManager(SessionManager *sm, QObject *parent)
: QObject(parent)
{
// Create backend
#ifdef ENABLE_SYSTEMD
m_backend = LogindBackend::create(sm);
if (!m_backend)
#endif
m_backend = FakeBackend::create();
qCDebug(LOGINMANAGER) << "Using" << m_backend->name() << "login manager backend";

Expand Down
16 changes: 14 additions & 2 deletions compositor/powermanager/powermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,20 @@
#include <QtDBus/QDBusConnectionInterface>

#include "powermanager.h"
#ifdef ENABLE_SYSTEMD
#include "systemdpowerbackend.h"
#endif
#include "upowerpowerbackend.h"

PowerManager::PowerManager(QObject *parent)
: QObject(parent)
{
QDBusConnectionInterface *interface = QDBusConnection::systemBus().interface();

#ifdef ENABLE_SYSTEMD
if (interface->isServiceRegistered(SystemdPowerBackend::service()))
m_backends.append(new SystemdPowerBackend());

#endif
if (interface->isServiceRegistered(UPowerPowerBackend::service()))
m_backends.append(new UPowerPowerBackend());

Expand Down Expand Up @@ -147,10 +150,14 @@ void PowerManager::serviceRegistered(const QString &service)
return;

// Otherwise add the most appropriate backend
#ifdef ENABLE_SYSTEMD
if (service == SystemdPowerBackend::service()) {
m_backends.append(new SystemdPowerBackend());
Q_EMIT capabilitiesChanged();
} else if (service == UPowerPowerBackend::service()) {
#else
if (service == UPowerPowerBackend::service()) {
#endif
m_backends.append(new UPowerPowerBackend());
Q_EMIT capabilitiesChanged();
}
Expand All @@ -166,12 +173,17 @@ void PowerManager::serviceUnregistered(const QString &service)
for (int i = 0; i < m_backends.size(); i++) {
PowerManagerBackend *backend = m_backends.at(i);

#ifdef ENABLE_SYSTEMD
if (service == SystemdPowerBackend::service() && backend->name() == QStringLiteral("systemd")) {
delete m_backends.takeAt(i);
Q_EMIT capabilitiesChanged();
return;
} else if (service == UPowerPowerBackend::service() && backend->name() == QStringLiteral("upower")) {
delete m_backends.takeAt(i);
#else
if (service == UPowerPowerBackend::service() && backend->name() == QStringLiteral("upower")) {

#endif
delete m_backends.takeAt(i);
Q_EMIT capabilitiesChanged();
return;
}
Expand Down
4 changes: 3 additions & 1 deletion data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
add_subdirectory(menu)
add_subdirectory(settings)
add_subdirectory(systemd)
if (ENABLE_SYSTEMD)
add_subdirectory(systemd)
endif()
add_subdirectory(wayland-sessions)