Introduction
Introduction Statistics Contact Development Disclaimer Help
added black window - slock - simple X display locker utility
git clone git://git.suckless.org/slock
Log
Files
Refs
README
LICENSE
---
commit 50bc1a788e8900cb40e8a64a22ddf99393dbe788
parent 763e52878dba100e79c6f4a837a92e1df0d41ae0
Author: Anselm R. Garbe <[email protected]>
Date: Wed, 11 Oct 2006 13:33:04 +0200
added black window
Diffstat:
M slock.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/slock.c b/slock.c
@@ -15,13 +15,15 @@
int
main(int argc, char **argv) {
char buf[32], passwd[256];
- int num, prev_nitem;
+ int num, prev_nitem, screen;
struct spwd *sp;
unsigned int i, len;
Bool running = True;
KeySym ksym;
Display *dpy;
+ Window w;
XEvent ev;
+ XSetWindowAttributes wa;
if((argc > 1) && !strncmp(argv[1], "-v", 3)) {
fputs("slock-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", s…
@@ -36,13 +38,23 @@ main(int argc, char **argv) {
fputs("slock: cannot open display\n", stderr);
exit(EXIT_FAILURE);
}
+ screen = DefaultScreen(dpy);
/* init */
passwd[0] = 0;
- while(XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync,
+ while(XGrabKeyboard(dpy, RootWindow(dpy, screen), True, GrabModeAsync,
GrabModeAsync, CurrentTime) != GrabSuccess)
usleep(1000);
+ wa.override_redirect = 1;
+ wa.background_pixel = BlackPixel(dpy, screen);
+ w = XCreateWindow(dpy, RootWindow(dpy, screen), 0, 0,
+ DisplayWidth(dpy, screen), DisplayHeight(dpy, screen),
+ 0, DefaultDepth(dpy, screen), CopyFromParent,
+ DefaultVisual(dpy, screen), CWOverrideRedirect | CWBac…
+ XMapRaised(dpy, w);
+ XSync(dpy, False);
+
/* main event loop */
while(running && !XNextEvent(dpy, &ev))
if(ev.type == KeyPress) {
@@ -66,7 +78,8 @@ main(int argc, char **argv) {
}
switch(ksym) {
case XK_Return:
- running = strncmp(crypt(passwd, sp->sp_pwdp), …
+ if((running = strncmp(crypt(passwd, sp->sp_pwd…
+ XBell(dpy, 100);
passwd[0] = 0;
break;
case XK_Escape:
@@ -87,6 +100,7 @@ main(int argc, char **argv) {
break;
}
}
+ XDestroyWindow(dpy, w);
XCloseDisplay(dpy);
return 0;
}
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.