summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjrun <darwinskernel@gmail.com>2023-01-05 14:17:55 -0500
committerGitHub <noreply@github.com>2023-01-05 20:17:55 +0100
commit0d14fd9136d7dbd731b02ce8501ff725f11b71cc (patch)
tree762f31d08fb83a93f32ad9f2b148676b1662833a /src
parent96198dae55b1429449504e49065a10763b288431 (diff)
add systemd support (#1253)
* add systemd support motivation for this is is proper ordering of related/bound/required services to Hyprland (e.g. swaybg) that would need to have a compositor ready. this could possibly be a build-time option of course. see also: example/ files for example of services Signed-off-by: Paymon MARANDI <darwinskernel@gmail.com> * nix: add withSystemd flag Signed-off-by: Paymon MARANDI <darwinskernel@gmail.com> Co-authored-by: Mihai Fufezan <fufexan@protonmail.com> Co-authored-by: Vaxerski <vaxry@vaxry.net>
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp12
-rw-r--r--src/main.cpp9
-rw-r--r--src/meson.build1
3 files changed, 22 insertions, 0 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 2c9ad503..b60d70d7 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -2,6 +2,9 @@
#include "helpers/Splashes.hpp"
#include <random>
#include "debug/HyprCtl.hpp"
+#ifdef USES_SYSTEMD
+#include <systemd/sd-daemon.h> // for sd_notify
+#endif
int handleCritSignal(int signo, void* data) {
Debug::log(LOG, "Hyprland received signal %d", signo);
@@ -384,6 +387,15 @@ void CCompositor::startCompositor() {
wlr_xcursor_manager_set_cursor_image(m_sWLRXCursorMgr, "left_ptr", m_sWLRCursor);
+#ifdef USES_SYSTEMD
+ if (sd_booted() > 0)
+ // tell systemd that we are ready so it can start other bond, following, related units
+ sd_notify(0, "READY=1");
+ else
+ Debug::log(LOG, "systemd integration is baked in but system itself is not booted à la systemd!");
+#endif
+
+
// This blocks until we are done.
Debug::log(LOG, "Hyprland is ready, running the event loop!");
wl_display_run(m_sWLDisplay);
diff --git a/src/main.cpp b/src/main.cpp
index 5b56944e..7d1353ba 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4,6 +4,9 @@
#include "config/ConfigManager.hpp"
#include "init/initHelpers.hpp"
#include <iostream>
+#ifdef USES_SYSTEMD
+#include <systemd/sd-daemon.h> // for sd_notify
+#endif
int main(int argc, char** argv) {
@@ -66,6 +69,12 @@ int main(int argc, char** argv) {
// If we are here it means we got yote.
Debug::log(LOG, "Hyprland reached the end.");
+#ifdef USES_SYSTEMD
+ // tell systemd it destroy bound/related units
+ if (sd_booted() > 0)
+ sd_notify(0, "STOPPING=1");
+#endif
+
wl_display_destroy_clients(g_pCompositor->m_sWLDisplay);
// kill all clients
diff --git a/src/meson.build b/src/meson.build
index a8fa7cfc..d7b1ec22 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -14,6 +14,7 @@ executable('Hyprland', src,
dependency('xkbcommon'),
dependency('libinput'),
xcb_dep,
+ systemd_dep,
dependency('pixman-1'),
dependency('gl', 'opengl'),