diff options
| author | auric <104602845+ihateamongus@users.noreply.github.com> | 2025-09-07 22:51:51 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-07 22:51:51 -0500 |
| commit | d11aec86841f77edd6eba3e07aa1e7e591e9da2a (patch) | |
| tree | 52f2894c784c83a352d0422b9656011f163934e4 /slock | |
| parent | 7993e7471ab97562eb24dd637952d2c8097f1168 (diff) | |
| parent | f37e068bf379ee688832c208312d46862e40c5ea (diff) | |
Merge pull request #16 from ihateamongus/codex/customize-slock-with-dynamic-logo-and-blur
Add accent-aware ASCII logo and blur to slock
Changed interval to be functional with 180hz instead of 60
Diffstat (limited to 'slock')
| -rw-r--r-- | slock/slock.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/slock/slock.c b/slock/slock.c index 2ecc59d..962cc1d 100644 --- a/slock/slock.c +++ b/slock/slock.c @@ -129,13 +129,17 @@ drawlogo(Display *dpy, struct lock *lock, const char *col) XftColor xftc; XGlyphInfo ext; int i, x, y, w, h, lines = 0, maxw = 0, lineh; + size_t len; w = DisplayWidth(dpy, lock->screen); h = DisplayHeight(dpy, lock->screen); lineh = font->ascent + font->descent; for (i = 0; icon[i]; i++) { - XftTextExtentsUtf8(dpy, font, (FcChar8 *)icon[i], strlen(icon[i]), &ext); + len = strlen(icon[i]); + while (len && icon[i][len - 1] == ' ') + len--; + XftTextExtentsUtf8(dpy, font, (FcChar8 *)icon[i], len, &ext); if (ext.xOff > maxw) maxw = ext.xOff; lines++; @@ -149,8 +153,11 @@ drawlogo(Display *dpy, struct lock *lock, const char *col) XClearWindow(dpy, lock->win); for (i = 0; icon[i]; i++) { + len = strlen(icon[i]); + while (len && icon[i][len - 1] == ' ') + len--; XftDrawStringUtf8(lock->draw, &xftc, font, x, y, - (FcChar8 *)icon[i], strlen(icon[i])); + (FcChar8 *)icon[i], len); y += lineh; } @@ -292,7 +299,8 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, pfd.events = POLLIN; while (running) { - if (poll(&pfd, 1, 1000) > 0) { + /* poll at ~60Hz so accent gradients appear smooth */ + if (poll(&pfd, 1, 5) > 0) { while (XPending(dpy)) { XNextEvent(dpy, &ev); if (ev.type == KeyPress) { |
