Updated barcolors patch

This commit is contained in:
kerberoge 2025-01-11 12:55:35 +01:00
parent 9e12e39f66
commit 9963c556ef

View File

@ -1,17 +1,25 @@
From 16f4f7cdc4ca9253a5bf97ee0e2ce5afd666fbbb Mon Sep 17 00:00:00 2001
From 6d9073e79a32fbb53fdd9579c8674d62b7b64eb7 Mon Sep 17 00:00:00 2001
From: Kerberoge <sjoerdenjh@gmail.com>
Date: Sun, 25 Aug 2024 22:41:55 +0200
Subject: [PATCH 1/1] applied barcolors patch
Subject: [PATCH 1/1] updated barcolors
---
dwl.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 83 insertions(+), 6 deletions(-)
dwl.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 84 insertions(+), 6 deletions(-)
diff --git a/dwl.c b/dwl.c
index ece537a..50d6ead 100644
index ece537a..cab15fb 100644
--- a/dwl.c
+++ b/dwl.c
@@ -318,6 +318,7 @@ static void destroykeyboardgroup(struct wl_listener *listener, void *data);
@@ -83,6 +83,7 @@
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
#define LISTEN_STATIC(E, H) do { static struct wl_listener _l = {.notify = (H)}; wl_signal_add((E), &_l); } while (0)
#define TEXTW(mon, text) (drwl_font_getwidth(mon->drw, text) + mon->lrpad)
+#define PREFIX(str, prefix) !strncmp(str, prefix, strlen(prefix))
/* enums */
enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
@@ -318,6 +319,7 @@ static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
static void drawbar(Monitor *m);
static void drawbars(void);
@ -19,7 +27,7 @@ index ece537a..50d6ead 100644
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
@@ -448,7 +449,7 @@ static struct wlr_box sgeom;
@@ -448,7 +450,7 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
@ -28,7 +36,7 @@ index ece537a..50d6ead 100644
static struct wl_event_source *status_event_source;
static const struct wlr_buffer_impl buffer_impl = {
@@ -1519,11 +1520,8 @@ drawbar(Monitor *m)
@@ -1519,11 +1521,8 @@ drawbar(Monitor *m)
return;
/* draw status first so it can be overdrawn by tags later */
@ -42,7 +50,7 @@ index ece537a..50d6ead 100644
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
@@ -1577,6 +1575,85 @@ drawbars(void)
@@ -1577,6 +1576,85 @@ drawbars(void)
drawbar(m);
}
@ -58,7 +66,7 @@ index ece537a..50d6ead 100644
+ for (p = stext; *p; p++) {
+ if (*p == '^') {
+ p++;
+ if (!strncmp(p, "fg(", 3) || !strncmp(p, "bg(", 3)) {
+ if (PREFIX(p, "fg(") || PREFIX(p, "bg(")) {
+ argend = strchr(p, ')');
+ if (!argend)
+ argend = p + 2;
@ -82,21 +90,21 @@ index ece537a..50d6ead 100644
+ for (p = stext; *p; p++) {
+ if (*p == '^') {
+ p++;
+ if (!strncmp(p, "fg(", 3) || !strncmp(p, "bg(", 3)) {
+ if (PREFIX(p, "fg(") || PREFIX(p, "bg(")) {
+ *(p - 1) = '\0';
+ iw = TEXTW(m, itext) - m->lrpad;
+ if (*itext) /* only draw text if there is something to draw */
+ x = drwl_text(m->drw, x, 0, iw, m->b.height, 0, itext, 0);
+ *(p - 1) = '^';
+
+ argstart = p + 3;
+ argstart = strchr(p, '(') + 1;
+ argend = strchr(argstart, ')');
+ if (!argend) argend = argstart - 1;
+ itext = argend + 1;
+
+ if (!strncmp(p, "fg(", 3)) /* foreground */
+ if (PREFIX(p, "fg("))
+ color = &scheme[0];
+ else /* background */
+ else
+ color = &scheme[1];
+
+ if (argend - argstart > 0) {
@ -105,7 +113,7 @@ index ece537a..50d6ead 100644
+ *color = *color << 8 | 0xff; /* add alpha channel */
+ *argend = ')';
+ } else {
+ *color = 0;
+ *color = 0; /* reset */
+ }
+
+ /* reset color back to normal if none was provided */