apply dpms patch

Turns the monitor off after some time.
master
Ryan 2023-09-20 17:42:27 -04:00
parent f8304db996
commit 81508c6538
Signed by: ryan
GPG Key ID: 7D7E2E94267DAD95
2 changed files with 24 additions and 0 deletions

View File

@ -36,3 +36,6 @@ static const int blurRadius=5;
//#define PIXELATION
/*Set pixelation radius*/
static const int pixelSize=0;
/* time in seconds before the monitor shuts down */
static const int monitortime = 5;

21
slock.c
View File

@ -19,6 +19,7 @@
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
#include <X11/extensions/dpms.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -392,6 +393,7 @@ main(int argc, char **argv) {
const char *hash;
Display *dpy;
int s, nlocks, nscreens;
CARD16 standby, suspend, off;
ARGBEGIN {
case 'v':
@ -506,6 +508,20 @@ main(int argc, char **argv) {
if (nlocks != nscreens)
return 1;
/* DPMS magic to disable the monitor */
if (!DPMSCapable(dpy))
die("slock: DPMSCapable failed\n");
if (!DPMSEnable(dpy))
die("slock: DPMSEnable failed\n");
if (!DPMSGetTimeouts(dpy, &standby, &suspend, &off))
die("slock: DPMSGetTimeouts failed\n");
if (!standby || !suspend || !off)
die("slock: at least one DPMS variable is zero\n");
if (!DPMSSetTimeouts(dpy, monitortime, monitortime, monitortime))
die("slock: DPMSSetTimeouts failed\n");
XSync(dpy, 0);
/* run post-lock command */
if (argc > 0) {
switch (fork()) {
@ -523,6 +539,10 @@ main(int argc, char **argv) {
/* everything is now blank. Wait for the correct password */
readpw(dpy, &rr, locks, nscreens, hash);
/* reset DPMS values to inital ones */
DPMSSetTimeouts(dpy, standby, suspend, off);
XSync(dpy, 0);
for (nlocks = 0, s = 0; s < nscreens; s++) {
XFreePixmap(dpy, locks[s]->drawable);
XFreeGC(dpy, locks[s]->gc);
@ -530,5 +550,6 @@ main(int argc, char **argv) {
XSync(dpy, 0);
XCloseDisplay(dpy);
return 0;
}