commit - d3dd1d86257e1b22b13be0cf11a6d21c44ca9ccc
commit + 394a8ca846595281a0d25cdaa8b9189db119285e
blob - f8148ac3ee2553004f8efa4165f5c037b1aaad6c
blob + f6d31201c7ec07d757d1e353ae697a94f48a1a8f
--- slock/slock.c
+++ slock/slock.c
Display *dpy;
int s, nlocks, nscreens;
CARD16 standby, suspend, off;
+ int working_dpms;
ARGBEGIN {
case 'v':
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);
-
+ working_dpms = DPMSCapable(dpy) == True;
+ if (working_dpms) {
+ 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);
+ } else {
+ fprintf(stderr, "slock: DPMS not supported\n");
+ }
/* run post-lock command */
if (argc > 0) {
#endif
/* reset DPMS values to inital ones */
- DPMSSetTimeouts(dpy, standby, suspend, off);
+ if (working_dpms)
+ DPMSSetTimeouts(dpy, standby, suspend, off);
+
XSync(dpy, 0);
return 0;