hyprctl: nullptr guard --systeminfo (#11822)

running Hyprland --systeminfo from a console/tty calls systemInfoRequest
without us having a g_pCompositor or g_pHyprOpengl, so just if check them
and make --systeminfo not segfault and atleast print what info we can.
This commit is contained in:
Tom Englund 2025-09-25 01:44:07 +02:00 committed by GitHub
parent ec9a72d9fb
commit 683fc77f80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1180,19 +1180,24 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request)
} else
result += "\tunknown: not runtime\n";
result += std::format("\nExplicit sync: {}", g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext ? "supported" : "missing");
result += std::format("\nGL ver: {}", g_pHyprOpenGL->m_eglContextVersion == CHyprOpenGLImpl::EGL_CONTEXT_GLES_3_2 ? "3.2" : "3.0");
result += std::format("\nBackend: {}", g_pCompositor->m_aqBackend->hasSession() ? "drm" : "sessionless");
if (g_pHyprOpenGL) {
result += std::format("\nExplicit sync: {}", g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext ? "supported" : "missing");
result += std::format("\nGL ver: {}", g_pHyprOpenGL->m_eglContextVersion == CHyprOpenGLImpl::EGL_CONTEXT_GLES_3_2 ? "3.2" : "3.0");
}
result += "\n\nMonitor info:";
if (g_pCompositor) {
result += std::format("\nBackend: {}", g_pCompositor->m_aqBackend->hasSession() ? "drm" : "sessionless");
for (const auto& m : g_pCompositor->m_monitors) {
result += std::format("\n\tPanel {}: {}x{}, {} {} {} {} -> backend {}\n\t\texplicit {}\n\t\tedid:\n\t\t\thdr {}\n\t\t\tchroma {}\n\t\t\tbt2020 {}\n\t\tvrr capable "
"{}\n\t\tnon-desktop {}\n\t\t",
m->m_name, sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), m->m_output->name, m->m_output->make, m->m_output->model, m->m_output->serial,
backend(m->m_output->getBackend()->type()), check(m->m_output->supportsExplicit), check(m->m_output->parsedEDID.hdrMetadata.has_value()),
check(m->m_output->parsedEDID.chromaticityCoords.has_value()), check(m->m_output->parsedEDID.supportsBT2020), check(m->m_output->vrrCapable),
check(m->m_output->nonDesktop));
result += "\n\nMonitor info:";
for (const auto& m : g_pCompositor->m_monitors) {
result += std::format("\n\tPanel {}: {}x{}, {} {} {} {} -> backend {}\n\t\texplicit {}\n\t\tedid:\n\t\t\thdr {}\n\t\t\tchroma {}\n\t\t\tbt2020 {}\n\t\tvrr capable "
"{}\n\t\tnon-desktop {}\n\t\t",
m->m_name, sc<int>(m->m_pixelSize.x), sc<int>(m->m_pixelSize.y), m->m_output->name, m->m_output->make, m->m_output->model, m->m_output->serial,
backend(m->m_output->getBackend()->type()), check(m->m_output->supportsExplicit), check(m->m_output->parsedEDID.hdrMetadata.has_value()),
check(m->m_output->parsedEDID.chromaticityCoords.has_value()), check(m->m_output->parsedEDID.supportsBT2020), check(m->m_output->vrrCapable),
check(m->m_output->nonDesktop));
}
}
if (g_pHyprCtl && g_pHyprCtl->m_currentRequestParams.sysInfoConfig) {