mirror of
https://github.com/mintycube/slock.git
synced 2024-10-22 14:05:51 +02:00
Adding auto-timeout patch
This commit is contained in:
parent
35fd53f6f2
commit
e5a9d8539b
@ -26,7 +26,7 @@ slock tool, how to install it and how it works.
|
|||||||
|
|
||||||
### Changelog:
|
### Changelog:
|
||||||
|
|
||||||
2021-09-09 - Added the failure-command and secret-password patches
|
2021-09-09 - Added the auto-timeout, failure-command and secret-password patches
|
||||||
|
|
||||||
2021-06-08 - Added the color message patch
|
2021-06-08 - Added the color message patch
|
||||||
|
|
||||||
@ -44,6 +44,9 @@ slock tool, how to install it and how it works.
|
|||||||
- enables transparency for slock
|
- enables transparency for slock
|
||||||
- intended to be combined with a compositor that can blur the transparent background
|
- intended to be combined with a compositor that can blur the transparent background
|
||||||
|
|
||||||
|
- [auto-timeout](https://tools.suckless.org/slock/patches/auto-timeout/)
|
||||||
|
- allows for a command to be executed after a specified time of inactivity
|
||||||
|
|
||||||
- [blur_pixelated_screen](https://tools.suckless.org/slock/patches/blur-pixelated-screen/)
|
- [blur_pixelated_screen](https://tools.suckless.org/slock/patches/blur-pixelated-screen/)
|
||||||
- sets the lockscreen picture to a blured or pixelated screenshot
|
- sets the lockscreen picture to a blured or pixelated screenshot
|
||||||
|
|
||||||
|
11
config.def.h
11
config.def.h
@ -56,6 +56,17 @@ static const float alpha = 0.9;
|
|||||||
/* treat a cleared input like a wrong password (color) */
|
/* treat a cleared input like a wrong password (color) */
|
||||||
static const int failonclear = 1;
|
static const int failonclear = 1;
|
||||||
|
|
||||||
|
#if AUTO_TIMEOUT_PATCH
|
||||||
|
/* length of time (seconds) until */
|
||||||
|
static const int timeoffset = 60;
|
||||||
|
|
||||||
|
/* should [command] be run only once? */
|
||||||
|
static const int runonce = 0;
|
||||||
|
|
||||||
|
/* command to be run after [time] has passed */
|
||||||
|
static const char *command = "doas poweroff";
|
||||||
|
#endif // AUTO_TIMEOUT_PATCH
|
||||||
|
|
||||||
#if FAILURE_COMMAND_PATCH
|
#if FAILURE_COMMAND_PATCH
|
||||||
/* number of failed password attempts until failcommand is executed.
|
/* number of failed password attempts until failcommand is executed.
|
||||||
Set to 0 to disable */
|
Set to 0 to disable */
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
#define ALPHA_PATCH 0
|
#define ALPHA_PATCH 0
|
||||||
|
|
||||||
|
/* This patch allows for a command to be executed after a specified time of inactivity.
|
||||||
|
* https://tools.suckless.org/slock/patches/auto-timeout/
|
||||||
|
*/
|
||||||
|
#define AUTO_TIMEOUT_PATCH 0
|
||||||
|
|
||||||
/* This patch sets the lockscreen picture to a blured or pixelated screenshot.
|
/* This patch sets the lockscreen picture to a blured or pixelated screenshot.
|
||||||
* This patch depends on the Imlib2 library, uncomment the relevant line in
|
* This patch depends on the Imlib2 library, uncomment the relevant line in
|
||||||
* config.mk when enabling this patch.
|
* config.mk when enabling this patch.
|
||||||
|
43
slock.c
43
slock.c
@ -33,9 +33,9 @@
|
|||||||
#if MEDIAKEYS_PATCH
|
#if MEDIAKEYS_PATCH
|
||||||
#include <X11/XF86keysym.h>
|
#include <X11/XF86keysym.h>
|
||||||
#endif // MEDIAKEYS_PATCH
|
#endif // MEDIAKEYS_PATCH
|
||||||
#if QUICKCANCEL_PATCH
|
#if QUICKCANCEL_PATCH || AUTO_TIMEOUT_PATCH
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif // QUICKCANCEL_PATCH
|
#endif // QUICKCANCEL_PATCH / AUTO_TIMEOUT_PATCH
|
||||||
#if DPMS_PATCH
|
#if DPMS_PATCH
|
||||||
#include <X11/extensions/dpms.h>
|
#include <X11/extensions/dpms.h>
|
||||||
#endif // DPMS_PATCH
|
#endif // DPMS_PATCH
|
||||||
@ -48,6 +48,10 @@ char *argv0;
|
|||||||
int failtrack = 0;
|
int failtrack = 0;
|
||||||
#endif // FAILURE_COMMAND_PATCH
|
#endif // FAILURE_COMMAND_PATCH
|
||||||
|
|
||||||
|
#if AUTO_TIMEOUT_PATCH
|
||||||
|
static time_t lasttouched;
|
||||||
|
int runflag = 0;
|
||||||
|
#endif // AUTO_TIMEOUT_PATCH
|
||||||
#if QUICKCANCEL_PATCH
|
#if QUICKCANCEL_PATCH
|
||||||
static time_t locktime;
|
static time_t locktime;
|
||||||
#endif // QUICKCANCEL_PATCH
|
#endif // QUICKCANCEL_PATCH
|
||||||
@ -193,6 +197,9 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
|||||||
#endif // PAMAUTH_PATCH
|
#endif // PAMAUTH_PATCH
|
||||||
int num, screen, running, failure, oldc;
|
int num, screen, running, failure, oldc;
|
||||||
unsigned int len, color;
|
unsigned int len, color;
|
||||||
|
#if AUTO_TIMEOUT_PATCH
|
||||||
|
time_t currenttime;
|
||||||
|
#endif // AUTO_TIMEOUT_PATCH
|
||||||
#if CAPSCOLOR_PATCH
|
#if CAPSCOLOR_PATCH
|
||||||
int caps;
|
int caps;
|
||||||
unsigned int indicators;
|
unsigned int indicators;
|
||||||
@ -213,11 +220,23 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
|||||||
caps = indicators & 1;
|
caps = indicators & 1;
|
||||||
|
|
||||||
#endif // CAPSCOLOR_PATCH
|
#endif // CAPSCOLOR_PATCH
|
||||||
while (running && !XNextEvent(dpy, &ev)) {
|
#if AUTO_TIMEOUT_PATCH
|
||||||
|
while (running)
|
||||||
|
#else
|
||||||
|
while (running && !XNextEvent(dpy, &ev))
|
||||||
|
#endif // AUTO_TIMEOUT_PATCH
|
||||||
|
{
|
||||||
|
#if AUTO_TIMEOUT_PATCH
|
||||||
|
while (XPending(dpy)) {
|
||||||
|
XNextEvent(dpy, &ev);
|
||||||
|
#endif // AUTO_TIMEOUT_PATCH
|
||||||
#if QUICKCANCEL_PATCH
|
#if QUICKCANCEL_PATCH
|
||||||
running = !((time(NULL) - locktime < timetocancel) && (ev.type == MotionNotify));
|
running = !((time(NULL) - locktime < timetocancel) && (ev.type == MotionNotify));
|
||||||
#endif // QUICKCANCEL_PATCH
|
#endif // QUICKCANCEL_PATCH
|
||||||
if (ev.type == KeyPress) {
|
if (ev.type == KeyPress) {
|
||||||
|
#if AUTO_TIMEOUT_PATCH
|
||||||
|
time(&lasttouched);
|
||||||
|
#endif // AUTO_TIMEOUT_PATCH
|
||||||
explicit_bzero(&buf, sizeof(buf));
|
explicit_bzero(&buf, sizeof(buf));
|
||||||
num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
|
num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
|
||||||
if (IsKeypadKey(ksym)) {
|
if (IsKeypadKey(ksym)) {
|
||||||
@ -394,6 +413,20 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
|||||||
for (screen = 0; screen < nscreens; screen++)
|
for (screen = 0; screen < nscreens; screen++)
|
||||||
XRaiseWindow(dpy, locks[screen]->win);
|
XRaiseWindow(dpy, locks[screen]->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if AUTO_TIMEOUT_PATCH
|
||||||
|
}
|
||||||
|
|
||||||
|
time(¤ttime);
|
||||||
|
|
||||||
|
if (currenttime >= lasttouched + timeoffset) {
|
||||||
|
if (!runonce || !runflag) {
|
||||||
|
runflag = 1;
|
||||||
|
system(command);
|
||||||
|
}
|
||||||
|
lasttouched = currenttime;
|
||||||
|
}
|
||||||
|
#endif // AUTO_TIMEOUT_PATCH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,6 +440,10 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
|||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
Cursor invisible;
|
Cursor invisible;
|
||||||
|
|
||||||
|
#if AUTO_TIMEOUT_PATCH
|
||||||
|
time(&lasttouched);
|
||||||
|
#endif // AUTO_TIMEOUT_PATCH
|
||||||
|
|
||||||
if (dpy == NULL || screen < 0 || !(lock = malloc(sizeof(struct lock))))
|
if (dpy == NULL || screen < 0 || !(lock = malloc(sizeof(struct lock))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user