Skip to content

Commit

Permalink
systemd: add HYPRLAND_NO_SD_NOTIFY
Browse files Browse the repository at this point in the history
fixes #4217
  • Loading branch information
vaxerski committed Dec 21, 2023
1 parent bc51a91 commit bd952dc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
18 changes: 8 additions & 10 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,12 @@ void CCompositor::initServer() {

initManagers(STAGE_PRIORITY);

if (const auto ENV = getenv("HYPRLAND_TRACE"); ENV && std::string(ENV) == "1")
if (envEnabled("HYPRLAND_TRACE"))
Debug::trace = true;

wlr_log_init(WLR_INFO, NULL);

const auto LOGWLR = getenv("HYPRLAND_LOG_WLR");
if (LOGWLR && std::string(LOGWLR) == "1")
if (envEnabled("HYPRLAND_LOG_WLR"))
wlr_log_init(WLR_DEBUG, Debug::wlrLog);
else
wlr_log_init(WLR_ERROR, Debug::wlrLog);
Expand Down Expand Up @@ -343,7 +342,7 @@ void CCompositor::cleanup() {
Debug::shuttingDown = true;

#ifdef USES_SYSTEMD
if (sd_booted() > 0)
if (sd_booted() > 0 && !envEnabled("HYPRLAND_NO_SD_NOTIFY"))
sd_notify(0, "STOPPING=1");
#endif

Expand Down Expand Up @@ -540,10 +539,11 @@ void CCompositor::startCompositor() {
g_pHyprRenderer->setCursorFromName("left_ptr");

#ifdef USES_SYSTEMD
if (sd_booted() > 0)
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
if (!envEnabled("HYPRLAND_NO_SD_NOTIFY"))
sd_notify(0, "READY=1");
} else
Debug::log(LOG, "systemd integration is baked in but system itself is not booted à la systemd!");
#endif

Expand Down Expand Up @@ -2598,9 +2598,7 @@ int CCompositor::getNewSpecialID() {
}

void CCompositor::performUserChecks() {
const auto atomicEnv = getenv("WLR_DRM_NO_ATOMIC");
const auto atomicEnvStr = std::string(atomicEnv ? atomicEnv : "");
if (g_pConfigManager->getInt("general:allow_tearing") == 1 && atomicEnvStr != "1") {
if (g_pConfigManager->getInt("general:allow_tearing") == 1 && !envEnabled("WLR_DRM_NO_ATOMIC")) {
g_pHyprNotificationOverlay->addNotification("You have enabled tearing, but immediate presentations are not available on your configuration. Try adding "
"env = WLR_DRM_NO_ATOMIC,1 to your config.",
CColor(0), 15000, ICON_WARNING);
Expand Down
7 changes: 7 additions & 0 deletions src/helpers/MiscFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,11 @@ uint32_t glFormatToType(uint32_t gl) {
GL_UNSIGNED_INT_2_10_10_10_REV :
#endif
GL_UNSIGNED_BYTE;
}

bool envEnabled(const std::string& env) {
const auto ENV = getenv(env.c_str());
if (!ENV)
return false;
return std::string(ENV) == "1";
}
1 change: 1 addition & 0 deletions src/helpers/MiscFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ std::vector<SCallstackFrameInfo> getBacktrace();
void throwError(const std::string& err);
uint32_t drmFormatToGL(uint32_t drm);
uint32_t glFormatToType(uint32_t gl);
bool envEnabled(const std::string& env);

template <typename... Args>
[[deprecated("use std::format instead")]] std::string getFormat(std::format_string<Args...> fmt, Args&&... args) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int main(int argc, char** argv) {

g_pCompositor->initServer();

if (!getenv("HYPRLAND_NO_RT") || configStringToInt(std::string(getenv("HYPRLAND_NO_RT"))) == 0)
if (!envEnabled("HYPRLAND_NO_RT"))
Init::gainRealTime();

Debug::log(LOG, "Hyprland init finished.");
Expand Down
4 changes: 1 addition & 3 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ extern "C" {
}

CHyprRenderer::CHyprRenderer() {
const auto ENV = getenv("WLR_DRM_NO_ATOMIC");

if (ENV && std::string(ENV) == "1")
if (envEnabled("WLR_DRM_NO_ATOMIC"))
m_bTearingEnvSatisfied = true;

if (g_pCompositor->m_sWLRSession) {
Expand Down

0 comments on commit bd952dc

Please sign in to comment.