ref: bc762e9c9294990c0d2480295637c792363dcc8c
dir: /patches/faces.patch/
diff a/main.c b/main.c 60a61 > Image *txtc; /* text color */ 81a83,179 > static char * > readall(int f, int *osz) > { > int bufsz, sz, n; > char *s; > > bufsz = 1023; > s = nil; > for(sz = 0;; sz += n){ > if(bufsz-sz < 1024){ > bufsz *= 2; > s = realloc(s, bufsz); > } > if((n = readn(f, s+sz, bufsz-sz-1)) < 1) > break; > } > if(n < 0 || sz < 1){ > free(s); > return nil; > } > s[sz] = 0; > *osz = sz; > > return s; > } > > enum { > Colrioback, > > /* the following group has to be in order, they are used by libframe */ > Colback, > Colhigh, > Colbord, > Coltext, > Colhtext, > > Coltitle, > Colltitle, > Colhold, > Collhold, > Colpalehold, > Colpaletext, > Colsize, > > /* menuhit */ > Colmenubar, > Colmenuback, > Colmenuhigh, > Colmenubord, > Colmenutext, > Colmenuhtext, > > Numcolors > }; > > typedef struct Color Color; > > struct Color { > char *id; > union { > u32int rgb; > char *path; > }; > int flags; > }; > > static Color theme[Numcolors] = { > [Colrioback] = {"rioback", {0x777777}, 0}, > [Colback] = {"back", {0xffffff}, 0}, > [Colhigh] = {"high", {0xcccccc}, 0}, > [Colbord] = {"border", {0x999999}, 0}, > [Coltext] = {"text", {DBlack>>8}, 0}, > [Colhtext] = {"htext", {DBlack>>8}, 0}, > [Coltitle] = {"title", {DGreygreen>>8}, 0}, > [Colltitle] = {"ltitle", {DPalegreygreen>>8}, 0}, > [Colhold] = {"hold", {DMedblue>>8}, 0}, > [Collhold] = {"lhold", {DGreyblue>>8}, 0}, > [Colpalehold] = {"palehold", {DPalegreyblue>>8}, 0}, > [Colpaletext] = {"paletext", {0x666666}, 0}, > [Colsize] = {"size", {DRed>>8}, 0}, > [Colmenubar] = {"menubar", {DDarkgreen>>8}, 1}, > [Colmenuback] = {"menuback", {0xeaffea}, 1}, > [Colmenuhigh] = {"menuhigh", {DDarkgreen>>8}, 1}, > [Colmenubord] = {"menubord", {DMedgreen>>8}, 1}, > [Colmenutext] = {"menutext", {DBlack>>8}, 1}, > [Colmenuhtext] = {"menuhtext", {0xeaffea}, 1}, > }; > > u32int > color2rgb(Color c, int scale) > { > return ((((c.rgb >> 16) & 0xff) / scale) << 24) | > ((((c.rgb >> 8) & 0xff) / scale) << 16) | > (((c.rgb & 0xff) / scale) << 8) | > 0xff; > } > 82a181,228 > themeload(char *s, int n) > { > int i; > char *t, *a[2], *e; > Image *newc; > u32int rgb; > > if((t = malloc(n+1)) == nil) > return; > memmove(t, s, n); > t[n] = 0; > > for(s = t; s != nil && *s; s = e){ > if((e = strchr(s, '\n')) != nil) > *e++ = 0; > if(tokenize(s, a, 2) == 2){ > for(i = 0; i < nelem(theme); i++) { > if(strcmp(theme[i].id, a[0]) == 0) { > rgb = strtoul(a[1], nil, 16); > if((newc = allocimage(display, Rect(0, 0, 1, 1), RGB24, 1, rgb<<8 | 0xff)) != nil) { > theme[i].rgb = rgb; > } > break; > } > } > } > } > free(t); > } > > char * > themestring(int *n) > { > char *s, *t, *e; > int i; > > if((t = malloc(512)) != nil){ > s = t; > e = s+512; > for(i = 0; i < nelem(theme); i++) > s = seprint(s, e, "%s\t%06ux\n", theme[i].id, theme[i].rgb); > *n = s - t; > } > > return t; > } > > void 99a246,256 > // load theme > int sz, f; > char *s; > > if((f = open("/dev/theme", OREAD|OCEXEC)) >= 0){ > if((s = readall(f, &sz)) != nil) > themeload(s, sz); > free(s); > close(f); > } > 101,104c258,263 < bgrnd = allocimagemix(display, DPalebluegreen, DWhite); < blue = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x008888FF); /* blue-green */ < left = allocimage(display, leftright, GREY1, 0, DWhite); < right = allocimage(display, leftright, GREY1, 0, DWhite); --- > bgrnd = allocimagemix(display, color2rgb(theme[Colback], 1), color2rgb(theme[Colback], 1)); > blue = allocimage(display, Rect(0,0,1,1), screen->chan, color2rgb(theme[Colltitle], 1), color2rgb(theme[Coltext], 1)); /* blue-green */ > left = allocimage(display, leftright, GREY1, color2rgb(theme[Coltext], 1), color2rgb(theme[Coltext], 1)); > right = allocimage(display, leftright, GREY1, color2rgb(theme[Coltext], 1), color2rgb(theme[Coltext], 1)); > txtc = allocimage(display, leftright, GREY1, color2rgb(theme[Colback], 1), color2rgb(theme[Coltext], 1)); > 142c301 < string(screen, r.min, display->black, ZP, datefont, date); --- > string(screen, r.min, txtc, ZP, datefont, date); 263c422 < center(mediumfont, r.min, f->str[Suser], display->black); --- > center(mediumfont, r.min, f->str[Suser], txtc); 266c425 < center(mediumfont, r.min, tstr, display->black); --- > center(mediumfont, r.min, tstr, txtc); 272c431 < center(tinyfont, r.min, f->str[Sdomain], display->black); --- > center(tinyfont, r.min, f->str[Sdomain], bgrnd); diff a/mkfile b/mkfile 6c6 < TARG=faces --- > TARG=facest