Skip to content

Commit bd9718e

Browse files
committed
compositor: Notify systemd when the compositor is started
Our compositor now notifies systemd when it is ready and can be used with notify units. Issue: #140
1 parent 37ccffe commit bd9718e

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/compositor/CMakeLists.txt

+16-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ include_directories(
99
${CMAKE_BINARY_DIR}/headers
1010
)
1111

12+
if(systemd_FOUND)
13+
include_directories(${systemd_INCLUDE_DIRS})
14+
endif()
15+
1216
add_definitions(
1317
-DQT_COMPOSITOR_QUICK
1418
)
@@ -69,14 +73,21 @@ qtwayland_add_protocol_server(SOURCES
6973

7074
qt5_add_resources(RESOURCES hawaii-shell.qrc)
7175

72-
add_executable(hawaii-shell ${SOURCES} ${RESOURCES})
73-
qt5_use_modules(hawaii-shell Quick Compositor)
74-
set_target_properties(hawaii-shell PROPERTIES
75-
LINK_FLAGS -L${WaylandServer_LIBDIR}
76+
set(LINK_FLAGS
77+
-L${WaylandServer_LIBDIR}
7678
)
77-
target_link_libraries(hawaii-shell
79+
set(LIBRARIES
7880
${GreenIsland_LIBRARIES}
7981
${WaylandServer_LIBRARIES}
8082
)
83+
if(systemd_FOUND)
84+
set(LINK_FLAGS "${LINK_FLAGS} -L${systemd_LIBDIR}")
85+
set(LIBRARIES ${LIBRARIES} ${systemd_LIBRARIES})
86+
endif()
87+
88+
add_executable(hawaii-shell ${SOURCES} ${RESOURCES})
89+
qt5_use_modules(hawaii-shell Quick Compositor)
90+
set_target_properties(hawaii-shell PROPERTIES LINK_FLAGS ${LINK_FLAGS})
91+
target_link_libraries(hawaii-shell ${LIBRARIES})
8192

8293
install(TARGETS hawaii-shell DESTINATION ${CMAKE_INSTALL_BINDIR})

src/compositor/main.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
#include "cmakedirs.h"
3737
#include "logging.h"
3838

39+
#if HAVE_SYSTEMD
40+
# include <systemd/sd-daemon.h>
41+
#endif
42+
3943
int main(int argc, char *argv[])
4044
{
4145
// Application
@@ -107,5 +111,13 @@ int main(int argc, char *argv[])
107111
// Show compositor window
108112
compositor->show();
109113

114+
#if HAVE_SYSTEMD
115+
sd_notifyf(0,
116+
"READY=1\n"
117+
"STATUS=Ready\n"
118+
"MAINPID=%llu",
119+
QCoreApplication::applicationPid());
120+
#endif
121+
110122
return app.exec();
111123
}

0 commit comments

Comments
 (0)