1
0
mirror of https://github.com/tiyn/slock.git synced 2026-02-22 07:14:48 +01:00

applying dpms patch

This commit is contained in:
TiynGER
2020-03-31 11:11:56 +02:00
parent aaf27e6c3a
commit d6130ebe6a
4 changed files with 480 additions and 0 deletions

20
slock.c
View File

@@ -15,6 +15,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/dpms.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -314,6 +315,7 @@ main(int argc, char **argv) {
const char *hash;
Display *dpy;
int s, nlocks, nscreens;
CARD16 standby, suspend, off;
ARGBEGIN {
case 'v':
@@ -374,6 +376,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()) {
@@ -391,5 +407,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;
}