(BTW, URL in the ebuild seems to be invalid) Added a few lines to be able to switch a notebook's backlight off when locking screen (configurable; patch appended). Please include it, if possible. Reproducible: Always Steps to Reproduce: 1. Patch original source with appended patch. 2. Either add -D CFGFILE=/path/to/config to CFLAGS or use default /etc/X11/slock.conf. 3. Compile, install, 4. Create a config file with line "pre_lock <some_cmd>" and "post_unlock <some_cmd>" (in my case "radeontool light on/off" Actual Results: as expected Expected Results: commands are executed. --- slock.c.orig 2008-05-06 13:34:02.000000000 +0200 +++ slock.c 2008-05-06 15:16:25.000000000 +0200 @@ -17,6 +17,28 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> +#ifndef CFGFILE +#define CFGFILE "/etc/X11/slock.conf" +#endif /* CFGFILE */ + +#define BUSIZE 256 +char bu[BUSIZE]; + +void +runcmd(const char *item) { + char *p, *pp; + FILE *cfg; + if (cfg = fopen(CFGFILE, "r")) + while (p = fgets(bu, BUSIZE, cfg)) + if (!strncmp(item, p, strlen(item))) { + for (p += strlen(item); isspace(*p); p++) + ; + for (pp = p + strlen(p) - 1; isspace(*pp); p--) + *pp = '\0'; + system(p); + } +} + void eprint(const char *errstr, ...) { va_list ap; @@ -79,6 +101,7 @@ /* init */ wa.override_redirect = 1; + runcmd("pre_lock"); wa.background_pixel = BlackPixel(dpy, screen); w = XCreateWindow(dpy, root, 0, 0, DisplayWidth(dpy, screen), DisplayHeight(dpy, screen), 0, DefaultDepth(dpy, screen), CopyFromParent, @@ -141,5 +164,6 @@ XFreePixmap(dpy, pmap); XDestroyWindow(dpy, w); XCloseDisplay(dpy); + runcmd("post_unlock"); return 0; }
I don't want to include this patch because it doesn't follow the principle of the suckless tools. You can have the same behavior with a simple script or an alias.