summaryrefslogtreecommitdiffstats
path: root/Makefile
Commit message (Expand)AuthorAgeFilesLines
* applied Sanders tiny patchesAnselm R.Garbe2006-08-081-1/+1
* typo fixarg@10ksloc.org2006-08-071-1/+1
* applied Sanders man page/Makefile patcharg@10ksloc.org2006-08-071-1/+1
* added stripping to dwm target in Makefilearg@10ksloc.org2006-08-071-0/+1
* removed CONFIGarg@10ksloc.org2006-08-031-3/+2
* make config.h not a time dependencearg@10ksloc.org2006-08-031-1/+1
* removed rm config.h from cleanarg@10ksloc.org2006-08-031-1/+1
* added gmake compliancearg@10ksloc.org2006-08-031-2/+2
* applied Jukka's diffarg@10ksloc.org2006-08-031-4/+5
* applied Sanders Makefile patcharg@10ksloc.org2006-08-031-26/+20
* using SRC instead of *.carg@10ksloc.org2006-08-031-1/+1
* changed the files included in make distarg@10ksloc.org2006-08-031-1/+2
* applied Sanders doc changes, added a PHONY line and changed the output of con...arg@10ksloc.org2006-08-031-1/+4
* implemented the idea presented by Sander for dwm targetarg@10ksloc.org2006-08-021-1/+4
* applied Sanders patchesarg@10ksloc.org2006-08-011-2/+1
* makefile now sets permissions for executables and man pagesarg@10ksloc.org2006-07-201-0/+6
* simplified MakefileAnselm R. Garbe2006-07-171-2/+2
* rearranged several stuffAnselm R. Garbe2006-07-151-1/+1
* rearrangedAnselm R. Garbe2006-07-141-1/+1
* draw bar on exposure ;)Anselm R. Garbe2006-07-141-1/+1
* prep 0.1Anselm R. Garbe2006-07-141-1/+1
* implemented bar for dwm (I miss status text), I plan that status text is read...Anselm R. Garbe2006-07-141-1/+1
* changed default colorsAnselm R. Garbe2006-07-131-2/+2
* added dev.c instead of kb.cAnselm R. Garbe2006-07-131-1/+1
* added logo+descriptionAnselm R. Garbe2006-07-131-12/+12
* removed unnecessary crapAnselm R. Garbe2006-07-131-16/+10
* added grid mode on Mod1Mask gAnselm R. Garbe2006-07-121-1/+1
* added mouse-based resizalsAnselm R. Garbe2006-07-111-1/+1
* removed unnecessary sel stuffAnselm R. Garbe2006-07-111-8/+2
* added gridsel to gridwmAnselm R. Garbe2006-07-111-2/+8
* added key handlingAnselm R. Garbe2006-07-111-1/+1
* added several other stuffAnselm R. Garbe2006-07-101-2/+2
* renamed gridmenu.c into menu.cAnselm R. Garbe2006-07-101-1/+1
* several new changes, made gridmenu workingAnselm R. Garbe2006-07-101-4/+10
* added new stuffAnselm R. Garbe2006-07-101-6/+6
* added gridmenuAnselm R. Garbe2006-07-101-3/+35
* initial importAnselm R. Garbe2006-07-101-0/+23
h.h> #endif enum { INIT, INPUT, FAILED, NUMCOLS }; #include "config.h" typedef struct { int screen; Window root, win; Pixmap pmap; unsigned long colors[NUMCOLS]; } Lock; static Lock **locks; static int nscreens; static Bool running = True; static Bool failure = False; static Bool rr; static int rrevbase; static int rrerrbase; static void die(const char *errstr, ...) { va_list ap; va_start(ap, errstr); vfprintf(stderr, errstr, ap); va_end(ap); exit(1); } #ifdef __linux__ #include <fcntl.h> #include <linux/oom.h> static void dontkillme(void) { int fd; int length; char value[64]; fd = open("/proc/self/oom_score_adj", O_WRONLY); if (fd < 0 && errno == ENOENT) return; /* convert OOM_SCORE_ADJ_MIN to string for writing */ length = snprintf(value, sizeof(value), "%d\n", OOM_SCORE_ADJ_MIN); /* bail on truncation */ if (length >= sizeof(value)) die("buffer too small\n"); if (fd < 0 || write(fd, value, length) != length || close(fd) != 0) die("cannot disable the out-of-memory killer for this process\n"); } #endif #ifndef HAVE_BSD_AUTH /* only run as root */ static const char * getpw(void) { const char *rval; struct passwd *pw; errno = 0; pw = getpwuid(getuid()); if (!pw) { if (errno) die("slock: getpwuid: %s\n", strerror(errno)); else die("slock: cannot retrieve password entry\n"); } rval = pw->pw_passwd; #if HAVE_SHADOW_H if (rval[0] == 'x' && rval[1] == '\0') { struct spwd *sp; sp = getspnam(getenv("USER")); if (!sp) die("slock: cannot retrieve shadow entry (make sure to suid or sgid slock)\n"); rval = sp->sp_pwdp; } #endif /* drop privileges */ if (geteuid() == 0 && ((getegid() != pw->pw_gid && setgid(pw->pw_gid) < 0) || setuid(pw->pw_uid) < 0)) die("slock: cannot drop privileges\n"); return rval; } #endif static void #ifdef HAVE_BSD_AUTH readpw(Display *dpy) #else readpw(Display *dpy, const char *pws) #endif { char buf[32], passwd[256]; int num, screen; unsigned int len, color; KeySym ksym; XEvent ev; static int oldc = INIT; len = 0; running = True; /* As "slock" stands for "Simple X display locker", the DPMS settings * had been removed and you can set it with "xset" or some other * utility. This way the user can easily set a customized DPMS * timeout. */ while (running && !XNextEvent(dpy, &ev)) { if (ev.type == KeyPress) { buf[0] = 0; num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0); if (IsKeypadKey(ksym)) { if (ksym == XK_KP_Enter) ksym = XK_Return; else if (ksym >= XK_KP_0 && ksym <= XK_KP_9) ksym = (ksym - XK_KP_0) + XK_0; } if (IsFunctionKey(ksym) || IsKeypadKey(ksym) || IsMiscFunctionKey(ksym) || IsPFKey(ksym) || IsPrivateKeypadKey(ksym)) continue; switch (ksym) { case XK_Return: passwd[len] = 0; #ifdef HAVE_BSD_AUTH running = !auth_userokay(getlogin(), NULL, "auth-xlock", passwd); #else running = !!strcmp(crypt(passwd, pws), pws); #endif if (running) { XBell(dpy, 100); failure = True; } len = 0; break; case XK_Escape: len = 0; break; case XK_BackSpace: if (len) --len; break; default: if (num && !iscntrl((int) buf[0]) && (len + num < sizeof(passwd))) { memcpy(passwd + len, buf, num); len += num; } break; } color = len ? INPUT : (failure || failonclear ? FAILED : INIT); if (running && oldc != color) { for (screen = 0; screen < nscreens; screen++) { XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]); XClearWindow(dpy, locks[screen]->win); } oldc = color; } } else if (rr && ev.type == rrevbase + RRScreenChangeNotify) { XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev; for (screen = 0; screen < nscreens; screen++) { if (locks[screen]->win == rre->window) { XResizeWindow(dpy, locks[screen]->win, rre->width, rre->height); XClearWindow(dpy, locks[screen]->win); } } } else for (screen = 0; screen < nscreens; screen++) XRaiseWindow(dpy, locks[screen]->win); } } static void unlockscreen(Display *dpy, Lock *lock) { if(dpy == NULL || lock == NULL) return; XUngrabPointer(dpy, CurrentTime); XFreeColors(dpy, DefaultColormap(dpy, lock->screen), lock->colors, NUMCOLS, 0); XFreePixmap(dpy, lock->pmap); XDestroyWindow(dpy, lock->win); free(lock); } static Lock * lockscreen(Display *dpy, int screen) { char curs[] = {0, 0, 0, 0, 0, 0, 0, 0}; unsigned int len; int i; Lock *lock; XColor color, dummy; XSetWindowAttributes wa; Cursor invisible; if (dpy == NULL || screen < 0) return NULL; lock = malloc(sizeof(Lock)); if (lock == NULL) return NULL; lock->screen = screen; lock->root = RootWindow(dpy, lock->screen); for (i = 0; i < NUMCOLS; i++) { XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), colorname[i], &color, &dummy); lock->colors[i] = color.pixel; } /* init */ wa.override_redirect = 1; wa.background_pixel = lock->colors[INIT]; lock->win = XCreateWindow(dpy, lock->root, 0, 0, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen), 0, DefaultDepth(dpy, lock->screen), CopyFromParent, DefaultVisual(dpy, lock->screen), CWOverrideRedirect | CWBackPixel, &wa); lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8); invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);