mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-06 07:01:57 -07:00
internal: add lock files and hyprctl instances
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user