Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- config:
- ```
- // Date display settings
- static const char *pswind_font = "Liberation Sans Mono:style=Regular:size=16";
- static const char *pswind_color = "#ffffff";
- static const int pswind_y_off = 0; // pixels relative to center
- ```
- readpw() part:
- ```
- // if len > 0 -> password input, if resetcolor -> media keys || escape pressed, else -> failed passwored input
- color = len ? INPUT : resetcolor ? INIT : ((failure || failonclear) ? FAILED : INIT);
- if (resetcolor) { --resetcolor; };
- if (running) {
- pthread_mutex_lock(&mutex);
- for (screen = 0; screen < nscreens; screen++) {
- if (oldc != color){
- XSetWindowBackground(dpy,
- locks[screen]->win,
- locks[screen]->colors[color]);
- XClearWindow(dpy, locks[screen]->win);
- /* Redraw time and date after screen cleared */
- draw_time(dpy, locks[screen]);
- draw_date(dpy, locks[screen]);
- };
- draw_pswind(dpy, locks[screen], failure);
- }
- if (failure) { --failure; };
- pthread_mutex_unlock(&mutex);
- oldc = color;
- }
- ```
- draw_pswind():
- ```
- static unsigned long prrnum = 0;
- static void draw_pswind(Display *dpy, struct lock *lock, int failure) {
- char pswindstr[25];
- if (failure) {
- snprintf(pswindstr, sizeof(pswindstr), "✕✕✕✕✕✕✕✕");
- } else {
- unsigned long rnum;
- if (getrandom(&rnum,sizeof(rnum),0) != sizeof(rnum)){
- srandom(time(NULL));
- rnum = random();
- };
- rnum &= 0xFF;
- if (prrnum == rnum) {
- ++rnum;
- };
- prrnum = rnum;
- char *sym[] = {"●", "⚫"}; // {"▪", "■"};
- snprintf(pswindstr, sizeof(pswindstr), "%s%s%s%s%s%s%s%s",
- sym[(rnum >> 0) & 1], sym[(rnum >> 1) & 1],
- sym[(rnum >> 2) & 1], sym[(rnum >> 3) & 1],
- sym[(rnum >> 4) & 1], sym[(rnum >> 5) & 1],
- sym[(rnum >> 6) & 1], sym[(rnum >> 7) & 1]);
- };
- XGlyphInfo ext;
- XftTextExtentsUtf8(dpy, pswindfont, (FcChar8*)pswindstr, strlen(pswindstr), &ext);
- int pswind_x = (lock->w - ext.xOff) / 2;
- int pswind_y = ((lock->h/6) * 5) + pswind_y_off;
- XClearArea(dpy, lock->win, pswind_x, pswind_y - pswindfont->ascent, ext.xOff,
- pswindfont->ascent + pswindfont->descent, False);
- XftDrawStringUtf8(lock->xftdraw, &lock->picol, pswindfont, pswind_x, pswind_y,
- (FcChar8*)pswindstr, strlen(pswindstr));
- XFlush(dpy);
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment