summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2023-08-08 16:16:34 +0200
committervaxerski <vaxry@vaxry.net>2023-08-08 16:16:40 +0200
commitc748f36939cdac74332dde3afb866ad35bea1825 (patch)
tree1ef2c1593bdfd8a42520e0b891aac9c9fade3b16 /src/Compositor.cpp
parentad3b8dddf993736fe2d716e4cdc5c079e511da2e (diff)
internal: add lock files and hyprctl instances
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index d1124bc1..ec70bb68 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -312,6 +312,8 @@ void CCompositor::cleanup() {
if (!m_sWLDisplay || m_bIsShuttingDown)
return;
+ removeLockFile();
+
m_bIsShuttingDown = true;
#ifdef USES_SYSTEMD
@@ -416,6 +418,23 @@ void CCompositor::initManagers(eManagersInitStage stage) {
}
}
+void CCompositor::createLockFile() {
+ const auto PATH = "/tmp/hypr/" + m_szInstanceSignature + ".lock";
+
+ std::ofstream ofs(PATH, std::ios::trunc);
+
+ ofs << m_iHyprlandPID << "\n" << m_szWLDisplaySocket << "\n";
+
+ ofs.close();
+}
+
+void CCompositor::removeLockFile() {
+ const auto PATH = "/tmp/hypr/" + m_szInstanceSignature + ".lock";
+
+ if (std::filesystem::exists(PATH))
+ std::filesystem::remove(PATH);
+}
+
void CCompositor::startCompositor() {
initAllSignals();
@@ -477,6 +496,8 @@ void CCompositor::startCompositor() {
Debug::log(LOG, "systemd integration is baked in but system itself is not booted à la systemd!");
#endif
+ createLockFile();
+
// This blocks until we are done.
Debug::log(LOG, "Hyprland is ready, running the event loop!");
wl_display_run(m_sWLDisplay);