Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 220593 - x11-misc/slock improvement (for notebooks)
Summary: x11-misc/slock improvement (for notebooks)
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement
Assignee: Cédric Krier
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-06 13:54 UTC by Eckard Brauer
Modified: 2008-05-06 15:22 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eckard Brauer 2008-05-06 13:54:48 UTC
(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;
 }
Comment 1 Cédric Krier gentoo-dev 2008-05-06 15:22:50 UTC
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.