From 2f8a36efc6c8dbbf02d7d01b2b0f62809514de9f Mon Sep 17 00:00:00 2001 From: Ryan Kes Date: Wed, 13 Mar 2019 20:39:22 +0100 Subject: [PATCH] added dpms patch --- PKGBUILD | 21 +++++++- config.h | 15 ++++++ slock-dpms-20170923-fa11589.diff | 84 ++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 config.h create mode 100644 slock-dpms-20170923-fa11589.diff diff --git a/PKGBUILD b/PKGBUILD index 2739a58..9a4216d 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -10,12 +10,31 @@ license=('MIT') depends=('libxext' 'libxrandr') source=("http://dl.suckless.org/tools/$pkgname-$pkgver.tar.gz") #source=("slock-$pkgver.tar.bz2::http://hg.suckless.org/slock/archive/$_pkgver.tar.gz") -md5sums=('f91dd5ba50ce7bd1842caeca067086a3') +md5sums=('f91dd5ba50ce7bd1842caeca067086a3' + '76c1d90cfb0a1da62a00caec951f48f7' + '2afeace988ef4eaf0a8a078aded7c4a0') +sha256sums=('b53849dbc60109a987d7a49b8da197305c29307fd74c12dc18af0d3044392e6a' + '209c5e9954f38f6dae8cc32f7c79bc0351eee5210f943912d1ff0c7a305a355c' + '0d5508c24ab2e870f1d807044c08c7c4f835e696267ecca7521b08f59bc803d1') + +_patches=("slock-dpms-20170923-fa11589.diff") + +source=("http://dl.suckless.org/st/$pkgname-$pkgver.tar.gz" + "config.h" + "${_patches[@]}") + prepare() { cd "$srcdir/slock-$pkgver" sed -i 's|static const char \*group = "nogroup";|static const char *group = "nobody";|' config.def.h sed -ri 's/((CPP|C|LD)FLAGS) =/\1 +=/g' config.mk + + for patch in "${_patches[@]}"; do + echo "Applying patch $(basename $patch)..." + patch -Np1 -i "$srcdir/$(basename $patch)" + done + + cp $srcdir/config.h config.h } build() { diff --git a/config.h b/config.h new file mode 100644 index 0000000..1428bb0 --- /dev/null +++ b/config.h @@ -0,0 +1,15 @@ +/* user and group to drop privileges to */ +static const char *user = "nobody"; +static const char *group = "nobody"; + +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 = 1; + +/* time in seconds before the monitor shuts down */ +static const int monitortime = 5; diff --git a/slock-dpms-20170923-fa11589.diff b/slock-dpms-20170923-fa11589.diff new file mode 100644 index 0000000..e0e5519 --- /dev/null +++ b/slock-dpms-20170923-fa11589.diff @@ -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 +@@ -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 +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -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) + { +@@ -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': +@@ -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\n"); ++ if (!DPMSEnable(dpy)) ++ die("slock: DPMSEnable failed\n"); ++ if (!DPMSGetTimeouts(dpy, &standby, &suspend, &off)) ++ die("slock: DPMSGetTimeouts failed\n"); ++ 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\n", strerror(errno)); + case 0: ++ monitorreset(dpy, standby, suspend, off); ++ + if (close(ConnectionNumber(dpy)) < 0) + die("slock: close: %s\n", strerror(errno)); + execvp(argv[0], argv); +@@ -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; + }