From ad259a55c004f281805e29dea9a02e18f9731b51 Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Mon, 1 Sep 2025 19:27:41 -0400 Subject: [PATCH] hiro/qt: Silence xdg-screensaver output Co-authored-by: Near <77224854+near-san@users.noreply.github.com> --- hiro/qt/application.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hiro/qt/application.cpp b/hiro/qt/application.cpp index 2a4ac487a..83475d1d6 100644 --- a/hiro/qt/application.cpp +++ b/hiro/qt/application.cpp @@ -51,7 +51,20 @@ auto pApplication::quit() -> void { auto pApplication::setScreenSaver(bool screenSaver) -> void { #if defined(DISPLAY_XORG) if(state().screenSaverXDG && state().screenSaverWindow) { + //when invoking this command on Linux under Xfce, the follow message is written to the terminal: + //"org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files" + //to silence this message, stdout and stderr are redirected to /dev/null while invoking this command. + auto fd = open("/dev/null", O_NONBLOCK); + auto fo = dup(STDOUT_FILENO); + auto fe = dup(STDERR_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); invoke("xdg-screensaver", screenSaver ? "resume" : "suspend", string{"0x", hex(state().screenSaverWindow)}); + dup2(fo, STDOUT_FILENO); + dup2(fe, STDERR_FILENO); + close(fd); + close(fo); + close(fe); } #endif }