linux: Use D-Bus to inhibit screensaver

This commit is contained in:
robxnano
2024-09-23 17:51:04 +01:00
parent 4bc1546596
commit 2748771cb3
9 changed files with 229 additions and 41 deletions

View File

@ -45,24 +45,6 @@ bool ToggleFullscreen(Display* dpy, Window win)
return true;
}
void InhibitScreensaver(Window win, bool suspend)
{
char id[11];
snprintf(id, sizeof(id), "0x%lx", win);
// Call xdg-screensaver
char* argv[4] = {(char*)"xdg-screensaver", (char*)(suspend ? "suspend" : "resume"), id, nullptr};
pid_t pid;
if (!posix_spawnp(&pid, "xdg-screensaver", nullptr, nullptr, argv, environ))
{
int status;
while (waitpid(pid, &status, 0) == -1)
;
INFO_LOG_FMT(VIDEO, "Started xdg-screensaver (PID = {})", pid);
}
}
#ifdef HAVE_XRANDR
XRRConfiguration::XRRConfiguration(Display* _dpy, Window _win)
: dpy(_dpy), win(_win), screenResources(nullptr), outputInfo(nullptr), crtcInfo(nullptr),