On 02/11/2012 01:50 PM, Joseph Iacobucci wrote:
> On 02/11/2012 05:03 AM, Anselm R Garbe wrote:
>> It does not contain other potential features that were requested
>> during the years, like displaying some text in case the user hits his
>> keyboard. Such features will be subject to future slock releases.
>
> Instead of text, I configured my slock to change the background color
> when there are keyboard presses. If the password check fails, then it
> goes back to the main color. People can have the existing behavior by
> making both colors the same.
>
Do to popular demand, I had attached a diff with slock-0.9.
I am sure it could be refactored, changing the background color in three
places duplicates code.
I started to look at slock-1.0 to port it, but the structure of the code
is changed enough that I don't have the time today to update it for
slock-1.0.
ps: don't hate on "skybue" and "bisque".
--
Joseph Iacobucci
[email protected]
diff -up /home/jiacobucci/Downloads/slock-0.9/slock.c ./slock.c
--- /home/jiacobucci/Downloads/slock-0.9/slock.c 2008-07-29 14:22:46.000000000 -0400
+++ ./slock.c 2012-02-12 13:13:57.024767373 -0500
@@ -76,7 +76,7 @@ main(int argc, char **argv) {
KeySym ksym;
Pixmap pmap;
Window root, w;
- XColor black, dummy;
+ XColor colour,dummy;
XEvent ev;
XSetWindowAttributes wa;
@@ -96,13 +96,13 @@ main(int argc, char **argv) {
/* init */
wa.override_redirect = 1;
- wa.background_pixel = BlackPixel(dpy, screen);
+ XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "skyblue", &colour, &dummy);
+ wa.background_pixel = colour.pixel;
w = XCreateWindow(dpy, root, 0, 0, DisplayWidth(dpy, screen), DisplayHeight(dpy, screen),
0, DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixel, &wa);
- XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "black", &black, &dummy);
pmap = XCreateBitmapFromData(dpy, w, curs, 8, 8);
- invisible = XCreatePixmapCursor(dpy, pmap, pmap, &black, &black, 0, 0);
+ invisible = XCreatePixmapCursor(dpy, pmap, pmap, &colour, &colour, 0, 0);
XDefineCursor(dpy, w, invisible);
XMapRaised(dpy, w);
for(len = 1000; len; len--) {
@@ -125,9 +125,11 @@ main(int argc, char **argv) {
/* main event loop */
while(running && !XNextEvent(dpy, &ev)) {
- if(len == 0 && DPMSCapable(dpy)) {
- DPMSEnable(dpy);
- DPMSForceLevel(dpy, DPMSModeOff);
+ if(len == 1) {
+ XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "bisque", &colour, &dummy);
+ wa.background_pixel = colour.pixel;
+ XChangeWindowAttributes(dpy, w, CWBackPixel, &wa);
+ XClearWindow(dpy, w);
}
if(ev.type == KeyPress) {
buf[0] = 0;
@@ -153,6 +155,10 @@ main(int argc, char **argv) {
if (running != 0)
XBell(dpy, 100);
len = 0;
+ XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "skyblue", &colour, &dummy);
+ wa.background_pixel = colour.pixel;
+ XChangeWindowAttributes(dpy, w, CWBackPixel, &wa);
+ XClearWindow(dpy, w);
break;
case XK_Escape:
len = 0;