mirror of https://github.com/bsnes-emu/bsnes
hiro/qt: Silence xdg-screensaver output
Co-authored-by: Near <77224854+near-san@users.noreply.github.com>
This commit is contained in:
parent
f83bc75270
commit
ad259a55c0
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue