aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkolunmi <kolunmi@tutanota.com>2023-02-14 18:00:41 -0700
committerkolunmi <kolunmi@tutanota.com>2023-02-14 18:00:41 -0700
commitfac42b84abed90e0abbdacb5ab5069ea3e55f9de (patch)
tree7de79b068a8e76f7d61d18a19ebccf59158651fc
parent6ff69669c3d77e47792103c7a71b93a7a14b885c (diff)
downloaddwlb-fac42b84abed90e0abbdacb5ab5069ea3e55f9de.tar.gz
rename color vars/options and add inactive_fg_color
-rw-r--r--config.def.h11
-rw-r--r--dwlb.c80
2 files changed, 49 insertions, 42 deletions
diff --git a/config.def.h b/config.def.h
index 683adf0..e7349f9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,8 +12,9 @@ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
// set 16-bit colors for bar
// 8-bit color can be converted to 16-bit color by simply duplicating values e.g
// 0x55 -> 0x5555, 0xf1 -> 0xf1f1
-static pixman_color_t activecolor = { .red = 0x0000, .green = 0x5555, .blue = 0x7777, .alpha = 0xffff, };
-static pixman_color_t inactivecolor = { .red = 0x2222, .green = 0x2222, .blue = 0x2222, .alpha = 0xffff, };
-static pixman_color_t textcolor = { .red = 0xeeee, .green = 0xeeee, .blue = 0xeeee, .alpha = 0xffff, };
-static pixman_color_t urgbgcolor = { .red = 0xeeee, .green = 0xeeee, .blue = 0xeeee, .alpha = 0xffff, };
-static pixman_color_t urgtextcolor = { .red = 0x2222, .green = 0x2222, .blue = 0x2222, .alpha = 0xffff, };
+static pixman_color_t active_fg_color = { .red = 0xeeee, .green = 0xeeee, .blue = 0xeeee, .alpha = 0xffff, };
+static pixman_color_t active_bg_color = { .red = 0x0000, .green = 0x5555, .blue = 0x7777, .alpha = 0xffff, };
+static pixman_color_t inactive_fg_color = { .red = 0xbbbb, .green = 0xbbbb, .blue = 0xbbbb, .alpha = 0xffff, };
+static pixman_color_t inactive_bg_color = { .red = 0x2222, .green = 0x2222, .blue = 0x2222, .alpha = 0xffff, };
+static pixman_color_t urgent_fg_color = { .red = 0x2222, .green = 0x2222, .blue = 0x2222, .alpha = 0xffff, };
+static pixman_color_t urgent_bg_color = { .red = 0xeeee, .green = 0xeeee, .blue = 0xeeee, .alpha = 0xffff, };
diff --git a/dwlb.c b/dwlb.c
index 8e946a3..2bd1c7c 100644
--- a/dwlb.c
+++ b/dwlb.c
@@ -60,11 +60,12 @@
" -hidden bars will initially be hidden\n" \
" -bottom bars will initially be drawn at the bottom\n" \
" -font [FONT] specify a font\n" \
- " -text-color [COLOR] specify text color\n" \
- " -active-color [COLOR] specify color to indicate active tags or monitors\n" \
- " -inactive-color [COLOR] specify color to indicate inactive tags or monitors\n" \
- " -urg-text-color [COLOR] specify text color on urgent tags\n" \
- " -urg-bg-color [COLOR] specify color of urgent tags\n" \
+ " -active-fg-color [COLOR] specify text color of active tags or monitors\n" \
+ " -active-bg-color [COLOR] specify background color of active tags or monitors\n" \
+ " -inactive-fg-color [COLOR] specify text color of inactive tags or monitors\n" \
+ " -inactive-fg-color [COLOR] specify background color of inactive tags or monitors\n" \
+ " -urgent-fg-color [COLOR] specify text color of urgent tags\n" \
+ " -urgent-bg-color [COLOR] specify background color of urgent tags\n" \
" -tags [FIRST TAG]...[LAST TAG] specify custom tag names\n" \
"Commands\n" \
" -status [OUTPUT] [TEXT] set status text\n" \
@@ -399,36 +400,36 @@ draw_frame(Bar *b)
if (hide_vacant && !active && !occupied && !urgent)
continue;
-
+
+ pixman_color_t *fg_color = urgent ? &urgent_fg_color : (active ? &active_fg_color : &inactive_fg_color);
+ pixman_color_t *bg_color = urgent ? &urgent_bg_color : (active ? &active_bg_color : &inactive_bg_color);
+
if (!hide_vacant && occupied)
pixman_image_fill_boxes(PIXMAN_OP_SRC, foreground,
- &textcolor, 1, &(pixman_box32_t){
+ fg_color, 1, &(pixman_box32_t){
.x1 = xpos_left + boxs, .x2 = xpos_left + boxs + boxw,
.y1 = boxs, .y2 = boxs + boxw
});
- if (urgent)
- xpos_left = draw_text(tags[i], xpos_left, ypos, foreground, background, &urgtextcolor,
- &urgbgcolor, b->width, b->height, b->textpadding, false);
- else
- xpos_left = draw_text(tags[i], xpos_left, ypos, foreground, background, &textcolor,
- active ? &activecolor : &inactivecolor, b->width, b->height,
- b->textpadding, false);
+ xpos_left = draw_text(tags[i], xpos_left, ypos, foreground, background, fg_color,
+ bg_color, b->width, b->height, b->textpadding, false);
}
- xpos_left = draw_text(b->layout, xpos_left, ypos, foreground, background, &textcolor,
- &inactivecolor, b->width, b->height, b->textpadding, false);
+ xpos_left = draw_text(b->layout, xpos_left, ypos, foreground, background, &inactive_fg_color,
+ &inactive_bg_color, b->width, b->height, b->textpadding, false);
uint32_t status_width = TEXT_WIDTH(b->status, b->width - xpos_left, b->textpadding, true);
- draw_text(b->status, b->width - status_width, ypos, foreground, background, &textcolor,
- &inactivecolor, b->width, b->height, b->textpadding, true);
+ draw_text(b->status, b->width - status_width, ypos, foreground,
+ background, &inactive_fg_color, &inactive_bg_color,
+ b->width, b->height, b->textpadding, true);
- xpos_left = draw_text(b->title, xpos_left, ypos, foreground, background, &textcolor,
- b->selmon ? &activecolor : &inactivecolor, b->width - status_width,
- b->height, b->textpadding, false);
+ xpos_left = draw_text(b->title, xpos_left, ypos, foreground, background,
+ b->selmon ? &active_fg_color : &inactive_fg_color,
+ b->selmon ? &active_bg_color : &inactive_bg_color,
+ b->width - status_width, b->height, b->textpadding, false);
pixman_image_fill_boxes(PIXMAN_OP_SRC, background,
- b->selmon ? &activecolor : &inactivecolor, 1,
+ b->selmon ? &active_bg_color : &inactive_bg_color, 1,
&(pixman_box32_t){
.x1 = xpos_left, .x2 = b->width - status_width,
.y1 = 0, .y2 = b->height
@@ -1038,30 +1039,35 @@ main(int argc, char **argv)
if (++i >= argc)
DIE("Option -font requires an argument");
fontstr = argv[i];
- } else if (!strcmp(argv[i], "-text-color")) {
+ } else if (!strcmp(argv[i], "-active-fg-color")) {
+ if (++i >= argc)
+ DIE("Option -active-fg-color requires an argument");
+ if (parse_color(argv[i], &active_fg_color) == -1)
+ DIE("malformed color string");
+ } else if (!strcmp(argv[i], "-active-bg-color")) {
if (++i >= argc)
- DIE("Option -text-color requires an argument");
- if (parse_color(argv[i], &textcolor) == -1)
+ DIE("Option -active-bg-color requires an argument");
+ if (parse_color(argv[i], &active_bg_color) == -1)
DIE("malformed color string");
- } else if (!strcmp(argv[i], "-active-color")) {
+ } else if (!strcmp(argv[i], "-inactive-fg-color")) {
if (++i >= argc)
- DIE("Option -active-color requires an argument");
- if (parse_color(argv[i], &activecolor) == -1)
+ DIE("Option -inactive-fg-color requires an argument");
+ if (parse_color(argv[i], &inactive_fg_color) == -1)
DIE("malformed color string");
- } else if (!strcmp(argv[i], "-inactive-color")) {
+ } else if (!strcmp(argv[i], "-inactive-bg-color")) {
if (++i >= argc)
- DIE("Option -inactive-color requires an argument");
- if (parse_color(argv[i], &inactivecolor) == -1)
+ DIE("Option -inactive-bg-color requires an argument");
+ if (parse_color(argv[i], &inactive_bg_color) == -1)
DIE("malformed color string");
- } else if (!strcmp(argv[i], "-urg-text-color")) {
+ } else if (!strcmp(argv[i], "-urgent-fg-color")) {
if (++i >= argc)
- DIE("Option -urg-text-color requires an argument");
- if (parse_color(argv[i], &urgtextcolor) == -1)
+ DIE("Option -urgent-fg-color requires an argument");
+ if (parse_color(argv[i], &urgent_fg_color) == -1)
DIE("malformed color string");
- } else if (!strcmp(argv[i], "-urg-bg-color")) {
+ } else if (!strcmp(argv[i], "-urgent-bg-color")) {
if (++i >= argc)
- DIE("Option -urg-bg-color requires an argument");
- if (parse_color(argv[i], &urgbgcolor) == -1)
+ DIE("Option -urgent-bg-color requires an argument");
+ if (parse_color(argv[i], &urgent_bg_color) == -1)
DIE("malformed color string");
} else if (!strcmp(argv[i], "-tags")) {
if (i + (int)LENGTH(tags) >= argc)