slock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 0bba46172d433ddb205fc66eaf6ce69e08688bcb
parent 74c66223a5743aba14789cfb07ffae1e9d4d6bc8
Author: bakkeby <bakkeby@gmail.com>
Date:   Mon,  3 Aug 2020 17:25:50 +0200

Adding alpha patch

Diffstat:
MREADME.md | 6+++++-
Mconfig.def.h | 7++++++-
Mpatches.def.h | 6++++++
Mslock.c | 8++++++++
4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md @@ -15,7 +15,7 @@ Refer to [https://tools.suckless.org/slock/](https://tools.suckless.org/slock/) ### Changelog: -2020-08-03 - Added keypress_feedback and blur_pixelated_screen patches +2020-08-03 - Added alpha, keypress_feedback and blur_pixelated_screen patches 2019-11-27 - Added xresources patch @@ -25,6 +25,10 @@ Refer to [https://tools.suckless.org/slock/](https://tools.suckless.org/slock/) ### Patches included: + - [alpha](https://github.com/khuedoan/slock) + - enables transparency for slock + - intended to be combined with a compositor that can blur the transparent background + - [blur_pixelated_screen](https://tools.suckless.org/slock/patches/blur-pixelated-screen/) - sets the lockscreen picture to a blured or pixelated screenshot diff --git a/config.def.h b/config.def.h @@ -1,6 +1,6 @@ /* user and group to drop privileges to */ static const char *user = "nobody"; -static const char *group = "nogroup"; +static const char *group = "nogroup"; // use "nobody" for arch static const char *colorname[NUMCOLS] = { [INIT] = "black", /* after initialization */ @@ -34,6 +34,11 @@ ResourcePref resources[] = { }; #endif // XRESOURCES_PATCH +#if ALPHA_PATCH +/* lock screen opacity */ +static const float alpha = 0.9; +#endif // ALPHA_PATCH + /* treat a cleared input like a wrong password (color) */ static const int failonclear = 1; diff --git a/patches.def.h b/patches.def.h @@ -9,6 +9,12 @@ /* Patches */ +/* This patch enables transparency for slock. This is intended to be combined + * with a compositor that can blur the transparent background. + * Extrapolated from https://github.com/khuedoan/slock + */ +#define ALPHA_PATCH 0 + /* This patch sets the lockscreen picture to a blured or pixelated screenshot. * This patch depends on the Imlib2 library, uncomment the relevant line in * config.mk when enabling this patch. diff --git a/slock.c b/slock.c @@ -20,6 +20,9 @@ #include <X11/Xutil.h> #include "patches.h" +#if ALPHA_PATCH +#include <X11/Xatom.h> +#endif // ALPHA_PATCH #if KEYPRESS_FEEDBACK_PATCH #include <time.h> #endif // KEYPRESS_FEEDBACK_PATCH @@ -439,6 +442,11 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen) #if QUICKCANCEL_PATCH locktime = time(NULL); #endif // QUICKCANCEL_PATCH + #if ALPHA_PATCH + unsigned int opacity = (unsigned int)(alpha * 0xffffffff); + XChangeProperty(dpy, lock->win, XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&opacity, 1L); + XSync(dpy, False); + #endif // ALPHA_PATCH return lock; }