Add patch to turn off the monitor after 5 sec.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/* See LICENSE file for license details. */
|
||||
#include <X11/Xmd.h>
|
||||
#define _XOPEN_SOURCE 500
|
||||
#if HAVE_SHADOW_H
|
||||
#include <shadow.h>
|
||||
@@ -15,6 +16,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>
|
||||
@@ -355,6 +357,8 @@ main(int argc, char **argv) {
|
||||
const char *hash;
|
||||
Display *dpy;
|
||||
int s, nlocks, nscreens;
|
||||
CARD16 standby, suspend, off;
|
||||
BOOL dpms_state;
|
||||
|
||||
ARGBEGIN {
|
||||
case 'v':
|
||||
@@ -415,6 +419,22 @@ 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 (!DPMSInfo(dpy, &standby, &dpms_state))
|
||||
die("slock: DPMSInfo failed\n");
|
||||
if (!DPMSEnable(dpy) && !dpms_state)
|
||||
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()) {
|
||||
@@ -435,5 +455,11 @@ 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);
|
||||
if (!dpms_state)
|
||||
DPMSDisable(dpy);
|
||||
XSync(dpy, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user