X-Git-Url: https://git.armaanb.net/?p=slock.git;a=blobdiff_plain;f=slock.c;h=2b06ca2a9c3b79c6ef7b9fe6fa2686edab91be7f;hp=4a10a9430b84db6978e58fe7af349fbeb15cd5e0;hb=716d7ac8524d47f244928ae45ca79194cfa2e7ff;hpb=476d719e840028f54ea3ed5c3fecffa54913d9f6 diff --git a/slock.c b/slock.c index 4a10a94..2b06ca2 100644 --- a/slock.c +++ b/slock.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -335,6 +336,7 @@ main(int argc, char **argv) { const char *hash; Display *dpy; int s, nlocks, nscreens; + CARD16 standby, suspend, off; ARGBEGIN { case 'v': @@ -395,6 +397,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()) { @@ -412,5 +428,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; }