From e53d62b39054cc411058398e54cb41fa10205232 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sun, 16 Jan 2022 13:14:35 +0100 Subject: Apply dpms patch --- slock.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'slock.c') diff --git a/slock.c b/slock.c index da9ffb2..3db79c8 100644 --- a/slock.c +++ b/slock.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -315,6 +316,7 @@ main(int argc, char **argv) { const char *hash; Display *dpy; int s, nlocks, nscreens; + CARD16 standby, suspend, off; ARGBEGIN { case 'v': @@ -375,6 +377,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()) { @@ -392,5 +408,9 @@ 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); + return 0; } -- cgit v1.2.3-70-g09d2