diff --git a/README.md b/README.md index cf4bbbd..af34994 100644 --- 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 index 406a00e..7a20086 100644 --- 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 index 02d77f7..e5494e1 100644 --- 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 index a8b37f1..e841ad3 100644 --- a/slock.c +++ b/slock.c @@ -20,6 +20,9 @@ #include #include "patches.h" +#if ALPHA_PATCH +#include +#endif // ALPHA_PATCH #if KEYPRESS_FEEDBACK_PATCH #include #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; }