update slock-dpms patch
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
From 4259049ca8d06a34c828c70298f3a8fdb8c5104c Mon Sep 17 00:00:00 2001
|
||||||
|
From: mortezadadgar <mortezadadgar97@gmail.com>
|
||||||
|
Date: Sat, 23 Sep 2023 18:45:58 +0330
|
||||||
|
Subject: [PATCH] Update to respect prevoius state of dpms
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 3 +++
|
||||||
|
slock.c | 26 ++++++++++++++++++++++++++
|
||||||
|
2 files changed, 29 insertions(+)
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index 9855e21..d01bd38 100644
|
index 9855e21..d01bd38 100644
|
||||||
--- a/config.def.h
|
--- a/config.def.h
|
||||||
@@ -8,12 +18,18 @@ index 9855e21..d01bd38 100644
|
|||||||
static const int failonclear = 1;
|
static const int failonclear = 1;
|
||||||
+
|
+
|
||||||
+/* time in seconds before the monitor shuts down */
|
+/* time in seconds before the monitor shuts down */
|
||||||
+static const int monitortime = 1;
|
+static const int monitortime = 5;
|
||||||
diff --git a/slock.c b/slock.c
|
diff --git a/slock.c b/slock.c
|
||||||
index d2f0886..f65a43b 100644
|
index 5ae738c..b5ac721 100644
|
||||||
--- a/slock.c
|
--- a/slock.c
|
||||||
+++ b/slock.c
|
+++ b/slock.c
|
||||||
@@ -15,6 +15,7 @@
|
@@ -1,4 +1,5 @@
|
||||||
|
/* See LICENSE file for license details. */
|
||||||
|
+#include <X11/Xmd.h>
|
||||||
|
#define _XOPEN_SOURCE 500
|
||||||
|
#if HAVE_SHADOW_H
|
||||||
|
#include <shadow.h>
|
||||||
|
@@ -15,6 +16,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <X11/extensions/Xrandr.h>
|
||||||
@@ -21,22 +37,25 @@ index d2f0886..f65a43b 100644
|
|||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
@@ -306,6 +307,7 @@ main(int argc, char **argv) {
|
@@ -314,6 +316,8 @@ main(int argc, char **argv) {
|
||||||
const char *hash;
|
const char *hash;
|
||||||
Display *dpy;
|
Display *dpy;
|
||||||
int s, nlocks, nscreens;
|
int s, nlocks, nscreens;
|
||||||
+ CARD16 standby, suspend, off;
|
+ CARD16 standby, suspend, off;
|
||||||
|
+ BOOL dpms_state;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'v':
|
case 'v':
|
||||||
@@ -366,6 +368,20 @@ main(int argc, char **argv) {
|
@@ -374,6 +378,22 @@ main(int argc, char **argv) {
|
||||||
if (nlocks != nscreens)
|
if (nlocks != nscreens)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
+ /* DPMS magic to disable the monitor */
|
+ /* DPMS magic to disable the monitor */
|
||||||
+ if (!DPMSCapable(dpy))
|
+ if (!DPMSCapable(dpy))
|
||||||
+ die("slock: DPMSCapable failed\n");
|
+ die("slock: DPMSCapable failed\n");
|
||||||
+ if (!DPMSEnable(dpy))
|
+ if (!DPMSInfo(dpy, &standby, &dpms_state))
|
||||||
|
+ die("slock: DPMSInfo failed\n");
|
||||||
|
+ if (!DPMSEnable(dpy) && !dpms_state)
|
||||||
+ die("slock: DPMSEnable failed\n");
|
+ die("slock: DPMSEnable failed\n");
|
||||||
+ if (!DPMSGetTimeouts(dpy, &standby, &suspend, &off))
|
+ if (!DPMSGetTimeouts(dpy, &standby, &suspend, &off))
|
||||||
+ die("slock: DPMSGetTimeouts failed\n");
|
+ die("slock: DPMSGetTimeouts failed\n");
|
||||||
@@ -50,13 +69,18 @@ index d2f0886..f65a43b 100644
|
|||||||
/* run post-lock command */
|
/* run post-lock command */
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
@@ -383,5 +399,9 @@ main(int argc, char **argv) {
|
@@ -391,5 +411,11 @@ main(int argc, char **argv) {
|
||||||
/* everything is now blank. Wait for the correct password */
|
/* everything is now blank. Wait for the correct password */
|
||||||
readpw(dpy, &rr, locks, nscreens, hash);
|
readpw(dpy, &rr, locks, nscreens, hash);
|
||||||
|
|
||||||
+ /* reset DPMS values to inital ones */
|
+ /* reset DPMS values to inital ones */
|
||||||
+ DPMSSetTimeouts(dpy, standby, suspend, off);
|
+ DPMSSetTimeouts(dpy, standby, suspend, off);
|
||||||
|
+ if (!dpms_state)
|
||||||
|
+ DPMSDisable(dpy);
|
||||||
+ XSync(dpy, 0);
|
+ XSync(dpy, 0);
|
||||||
+
|
+
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
--
|
||||||
|
2.42.0
|
||||||
|
|
||||||
Reference in New Issue
Block a user