commit d95e230936dac40edd889d8c1c8be909a265779a
parent f61396d0550c7f107e3f0a9de00a9f188516ece2
Author: miksa234 <milutin@popovic.xyz>
Date: Fri, 23 Jul 2021 01:12:07 +0200
suspend in lockscreen patch
Diffstat:
7 files changed, 120 insertions(+), 20 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -6,20 +6,23 @@ static const char *colorname[NUMCOLS] = {
[BACKGROUND] = "black", /* after initialization */
[INIT] = "#2d2d2d", /* after initialization */
[INPUT] = "#632328", /* during input */
- [FAILED] = "#CC3333", /* wrong password */
+ [FAILED] = "#a6a28c", /* wrong password */
};
/* treat a cleared input like a wrong password (color) */
-static const int failonclear = 0;
+static const int failonclear = 1;
+
+/* time in seconds before the monitor shuts down */
+static const int monitortime = 5;
/* insert grid pattern with scale 1:1, the size can be changed with logosize */
static const int logosize = 20;
static const int logow = 12; /* grid width and height for right center alignment*/
static const int logoh = 20;
-static XRectangle rectangles[9] = {
+/*static XRectangle rectangles[9] = {*/
/* x y w h */
- { 0, 3, 1, 3 },
+/* { 0, 3, 1, 3 },
{ 1, 3, 2, 1 },
{ 0, 5, 8, 1 },
{ 3, 0, 1, 5 },
@@ -30,3 +33,15 @@ static XRectangle rectangles[9] = {
{ 11, 4, 1, 2 },
};
+*/
+
+static XRectangle rectangles[9] = {
+ /* x y w h */
+ { 0, 4, 1, 2 },
+ { 1, 2, 1, 2 },
+ { 2, 0, 1, 2 },
+ { 4, 0, 1, 6 },
+ { 4, 0, 3, 1 },
+ { 4, 5, 3, 1 },
+ { 6, 0, 1, 6 },
+};
diff --git a/config.def.h.orig b/config.def.h.orig
@@ -1,12 +0,0 @@
-/* user and group to drop privileges to */
-static const char *user = "miksa";
-static const char *group = "wheel";
-
-static const char *colorname[NUMCOLS] = {
- [INIT] = "black", /* after initialization */
- [INPUT] = "#005577", /* during input */
- [FAILED] = "#CC3333", /* wrong password */
-};
-
-/* treat a cleared input like a wrong password (color) */
-static const int failonclear = 0;
diff --git a/config.h b/config.h
@@ -6,20 +6,23 @@ static const char *colorname[NUMCOLS] = {
[BACKGROUND] = "black", /* after initialization */
[INIT] = "#2d2d2d", /* after initialization */
[INPUT] = "#632328", /* during input */
- [FAILED] = "#CC3333", /* wrong password */
+ [FAILED] = "#a6a28c", /* wrong password */
};
/* treat a cleared input like a wrong password (color) */
-static const int failonclear = 0;
+static const int failonclear = 1;
+
+/* time in seconds before the monitor shuts down */
+static const int monitortime = 5;
/* insert grid pattern with scale 1:1, the size can be changed with logosize */
static const int logosize = 20;
static const int logow = 12; /* grid width and height for right center alignment*/
static const int logoh = 20;
-static XRectangle rectangles[9] = {
+/*static XRectangle rectangles[9] = {*/
/* x y w h */
- { 0, 3, 1, 3 },
+/* { 0, 3, 1, 3 },
{ 1, 3, 2, 1 },
{ 0, 5, 8, 1 },
{ 3, 0, 1, 5 },
@@ -30,3 +33,15 @@ static XRectangle rectangles[9] = {
{ 11, 4, 1, 2 },
};
+*/
+
+static XRectangle rectangles[9] = {
+ /* x y w h */
+ { 0, 4, 1, 2 },
+ { 1, 2, 1, 2 },
+ { 2, 0, 1, 2 },
+ { 4, 0, 1, 6 },
+ { 4, 0, 3, 1 },
+ { 4, 5, 3, 1 },
+ { 6, 0, 1, 6 },
+};
diff --git a/patches/slock-dpms-1.4.diff b/patches/slock-dpms-1.4.diff
@@ -0,0 +1,62 @@
+diff --git a/config.def.h b/config.def.h
+index 9855e21..d01bd38 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -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..f65a43b 100644
+--- a/slock.c
++++ b/slock.c
+@@ -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>
+@@ -306,6 +307,7 @@ main(int argc, char **argv) {
+ const char *hash;
+ Display *dpy;
+ int s, nlocks, nscreens;
++ CARD16 standby, suspend, off;
+
+ ARGBEGIN {
+ case 'v':
+@@ -366,6 +368,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()) {
+@@ -383,5 +399,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;
+ }
diff --git a/slock b/slock
Binary files differ.
diff --git a/slock.c b/slock.c
@@ -19,6 +19,7 @@
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
+#include <X11/extensions/dpms.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -374,6 +375,7 @@ main(int argc, char **argv) {
const char *hash;
Display *dpy;
int s, nlocks, nscreens;
+ CARD16 standby, suspend, off;
ARGBEGIN {
case 'v':
@@ -434,6 +436,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()) {
@@ -451,6 +467,10 @@ 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);
+
for (nlocks = 0, s = 0; s < nscreens; s++) {
XFreePixmap(dpy, locks[s]->drawable);
XFreeGC(dpy, locks[s]->gc);
diff --git a/slock.o b/slock.o
Binary files differ.