From 5e7a95b50fd72efcf2a40d487278749a17cbb146 Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Sun, 9 Jun 2019 23:20:38 +0700 Subject: [PATCH] Add alpha option to change lock screen opacity Useful with compton blur effect --- config.def.h | 3 +++ config.h | 3 +++ slock.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/config.def.h b/config.def.h index 3d37dca..d7c11a1 100644 --- a/config.def.h +++ b/config.def.h @@ -8,6 +8,9 @@ static const char *colorname[NUMCOLS] = { [FAILED] = "#CC3333", /* wrong password */ }; +/* lock screen opacity */ +static const float alpha = 1; + /* treat a cleared input like a wrong password (color) */ static const int failonclear = 1; diff --git a/config.h b/config.h index 234315f..a25075d 100644 --- a/config.h +++ b/config.h @@ -8,6 +8,9 @@ static const char *colorname[NUMCOLS] = { [FAILED] = "#FF5555", /* wrong password */ }; +/* lock screen opacity */ +static const float alpha = 1; + /* treat a cleared input like a wrong password (color) */ static const int failonclear = 1; diff --git a/slock.c b/slock.c index 968fbf1..4b8e12e 100644 --- a/slock.c +++ b/slock.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "arg.h" #include "util.h" @@ -334,6 +335,9 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen) XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask); XSelectInput(dpy, lock->root, SubstructureNotifyMask); + 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); return lock; }