[wiki] [sites] [slock] Add dpms patch || Alvar Penning
commit 8c0d52bbe1e06fee0eb86a79f3e1aea0d067d5ab
Author: Alvar Penning <post_AT_0x21.biz>
Date: Sat Sep 23 16:15:10 2017 +0200
[slock] Add dpms patch
diff --git a/tools.suckless.org/slock/patches/dpms.md b/tools.suckless.org/slock/patches/dpms.md
new file mode 100644
index 00000000..7986b992
--- /dev/null
+++ b/tools.suckless.org/slock/patches/dpms.md
_AT_@ -0,0 +1,29 @@
+DPMS
+====
+
+Description
+-----------
+
+This patch interacts with the Display Power Signaling and automatically shuts
+down the monitor after a configurable amount of seconds. The monitor will
+automatically be activated by pressing a key or moving the mouse and the
+password can be entered then.
+
+Notes
+-----
+
+The number of seconds until the screen will be disabled is configured
+in `config.h` via the `monitortime` option.
+
+This patch was written against the `1.4`-tag.
+
+
+Download
+--------
+
+* [slock-dpms-20170923-fa11589.diff](slock-dpms-20170923-fa11589.diff)
+
+Authors
+-------
+
+* Alvar Penning <[post_AT_0x21.biz](mailto:post_AT_0x21.biz)>
diff --git a/tools.suckless.org/slock/patches/slock-dpms-20170923-fa11589.diff b/tools.suckless.org/slock/patches/slock-dpms-20170923-fa11589.diff
new file mode 100644
index 00000000..e0e55196
--- /dev/null
+++ b/tools.suckless.org/slock/patches/slock-dpms-20170923-fa11589.diff
_AT_@ -0,0 +1,84 @@
+diff --git a/config.def.h b/config.def.h
+index 9855e21..d01bd38 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -10,3 +10,6 @@ static const char *colorname[NUMCOLS] = {
+
+ /* treat a cleared input like a wrong password (color) */
+ static const int failonclear = 1;
++
++/* time in seconds before the monitor shuts down */
++static const int monitortime = 5;
+diff --git a/slock.c b/slock.c
+index d2f0886..7ab0521 100644
+--- a/slock.c
++++ b/slock.c
+_AT_@ -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>
+_AT_@ -289,6 +290,14 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
+ return NULL;
+ }
+
++static void
++monitorreset(Display* dpy, CARD16 standby, CARD16 suspend, CARD16 off)
++{
++ DPMSSetTimeouts(dpy, standby, suspend, off);
++ DPMSForceLevel(dpy, DPMSModeOn);
++ XFlush(dpy);
++}
++
+ static void
+ usage(void)
+ {
+_AT_@ -306,6 +315,7 @@ main(int argc, char **argv) {
+ const char *hash;
+ Display *dpy;
+ int s, nlocks, nscreens;
++ CARD16 standby, suspend, off;
+
+ ARGBEGIN {
+ case 'v':
+_AT_@ -366,12 +376,28 @@ main(int argc, char **argv) {
+ if (nlocks != nscreens)
+ return 1;
+
++ /* DPMS-magic to disable the monitor */
++ if (!DPMSCapable(dpy))
++ die("slock: DPMSCapable failed
");
++ if (!DPMSEnable(dpy))
++ die("slock: DPMSEnable failed
");
++ if (!DPMSGetTimeouts(dpy, &standby, &suspend, &off))
++ die("slock: DPMSGetTimeouts failed
");
++ if (!standby || !suspend || !off)
++ /* set values if there arent some */
++ standby = suspend = off = 300;
++
++ DPMSSetTimeouts(dpy, monitortime, monitortime, monitortime);
++ XFlush(dpy);
++
+ /* run post-lock command */
+ if (argc > 0) {
+ switch (fork()) {
+ case -1:
+ die("slock: fork failed: %s
", strerror(errno));
+ case 0:
++ monitorreset(dpy, standby, suspend, off);
++
+ if (close(ConnectionNumber(dpy)) < 0)
+ die("slock: close: %s
", strerror(errno));
+ execvp(argv[0], argv);
+_AT_@ -383,5 +409,8 @@ 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 */
++ monitorreset(dpy, standby, suspend, off);
++
+ return 0;
+ }
Received on Sat Sep 23 2017 - 16:15:32 CEST
This archive was generated by hypermail 2.3.0
: Sat Sep 23 2017 - 16:24:22 CEST