void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

0003-patch-dpms.patch (2226B)


      1https://tools.suckless.org/slock/patches/dpms/
      2
      3From 7c0aadbed47bff19657ed4b4555d1f554ef50293 Mon Sep 17 00:00:00 2001
      4From: Dash Eclipse <dashezup@disroot.org>
      5Date: Thu, 16 Jul 2020 10:16:08 +0000
      6Subject: [PATCH 3/3] patch dpms
      7
      8---
      9 config.def.h |  3 +++
     10 slock.c      | 20 ++++++++++++++++++++
     11 2 files changed, 23 insertions(+)
     12
     13diff --git a/config.def.h b/config.def.h
     14index e6bdf97..90f5b1d 100644
     15--- a/config.def.h
     16+++ b/config.def.h
     17@@ -12,6 +12,9 @@ static const char *colorname[NUMCOLS] = {
     18 /* treat a cleared input like a wrong password (color) */
     19 static const int failonclear = 1;
     20 
     21+/* time in seconds before the monitor shuts down */
     22+static const int monitortime = 5;
     23+
     24 /* default message */
     25 static const char * message = "Suckless: Software that sucks less.";
     26 
     27diff --git a/slock.c b/slock.c
     28index f6a3ca8..5aa7d47 100644
     29--- a/slock.c
     30+++ b/slock.c
     31@@ -15,6 +15,7 @@
     32 #include <unistd.h>
     33 #include <sys/types.h>
     34 #include <X11/extensions/Xrandr.h>
     35+#include <X11/extensions/dpms.h>
     36 #include <X11/extensions/Xinerama.h>
     37 #include <X11/keysym.h>
     38 #include <X11/Xlib.h>
     39@@ -412,6 +413,7 @@ main(int argc, char **argv) {
     40 	const char *hash;
     41 	Display *dpy;
     42 	int i, s, nlocks, nscreens;
     43+	CARD16 standby, suspend, off;
     44 	int count_fonts;
     45 	char **font_names;
     46 
     47@@ -487,6 +489,20 @@ main(int argc, char **argv) {
     48 	if (nlocks != nscreens)
     49 		return 1;
     50 
     51+	/* DPMS magic to disable the monitor */
     52+	if (!DPMSCapable(dpy))
     53+		die("slock: DPMSCapable failed\n");
     54+	if (!DPMSEnable(dpy))
     55+		die("slock: DPMSEnable failed\n");
     56+	if (!DPMSGetTimeouts(dpy, &standby, &suspend, &off))
     57+		die("slock: DPMSGetTimeouts failed\n");
     58+	if (!standby || !suspend || !off)
     59+		die("slock: at least one DPMS variable is zero\n");
     60+	if (!DPMSSetTimeouts(dpy, monitortime, monitortime, monitortime))
     61+		die("slock: DPMSSetTimeouts failed\n");
     62+
     63+	XSync(dpy, 0);
     64+
     65 	/* run post-lock command */
     66 	if (argc > 0) {
     67 		switch (fork()) {
     68@@ -504,5 +520,9 @@ main(int argc, char **argv) {
     69 	/* everything is now blank. Wait for the correct password */
     70 	readpw(dpy, &rr, locks, nscreens, hash);
     71 
     72+	 /* reset DPMS values to inital ones */
     73+	DPMSSetTimeouts(dpy, standby, suspend, off);
     74+	XSync(dpy, 0);
     75+
     76 	return 0;
     77 }
     78-- 
     792.27.0
     80