hiro/qt: Silence xdg-screensaver output

Co-authored-by: Near <77224854+near-san@users.noreply.github.com>
This commit is contained in:
John Chadwick 2025-09-01 19:27:41 -04:00 committed by Screwtapello
parent f83bc75270
commit ad259a55c0
1 changed files with 13 additions and 0 deletions

View File

@ -51,7 +51,20 @@ auto pApplication::quit() -> void {
auto pApplication::setScreenSaver(bool screenSaver) -> void { auto pApplication::setScreenSaver(bool screenSaver) -> void {
#if defined(DISPLAY_XORG) #if defined(DISPLAY_XORG)
if(state().screenSaverXDG && state().screenSaverWindow) { 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)}); 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 #endif
} }