From fb894f7213513e93c6c71332f13c711f398b41a9 Mon Sep 17 00:00:00 2001
From: Alfred Neumayer <dev.beidl@gmail.com>
Date: Sun, 25 Feb 2024 01:54:58 +0100
Subject: [PATCH] src: Enable builds without Lomiri System Compositor
 integration

Useful for distributions without LSC in their configuration.
Required CMake config: -DREPOWERD_ENABLE_LSC=ON
---
 CMakeLists.txt                     | 5 +++++
 src/core/default_state_machine.cpp | 5 +++++
 2 files changed, 10 insertions(+)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,7 @@
 
 option(REPOWERD_ENABLE_HYBRIS "Enable hybris support" ON)
 option(REPOWERD_ENABLE_BINDER "Enable binder support" ON)
+option(REPOWERD_ENABLE_LSC "Enable Lomiri System Compositor integration" ON)
 
 # Work around cmake setting conf dir to "/usr/etc" instead of "/etc"
 # when prefix is "/usr"
@@ -43,6 +44,10 @@
 pkg_check_modules(GIO REQUIRED gio-2.0)
 pkg_check_modules(GIO_UNIX REQUIRED gio-unix-2.0)
 
+if (REPOWERD_ENABLE_LSC)
+    add_definitions(-DREPOWERD_ENABLE_LSC)
+endif()
+
 if (REPOWERD_ENABLE_HYBRIS)
     find_library(Hybris NAMES hybris-common REQUIRED)
     pkg_check_modules(ANDROIDPROPERTIES REQUIRED libandroid-properties)
--- a/src/core/default_state_machine.cpp
+++ b/src/core/default_state_machine.cpp
@@ -125,6 +125,11 @@
 
 void repowerd::DefaultStateMachine::handle_alarm(AlarmId id)
 {
+    // This needs Lomiri System Compositor to function
+#ifndef REPOWERD_ENABLE_LSC
+    return;
+#endif
+
     if (id == power_button_long_press_alarm_id)
     {
         log->logDebug(log_tag, "handle_alarm(long_press)");
