aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkolunmi <kolunmi@tutanota.com>2023-02-16 11:09:53 -0700
committerkolunmi <kolunmi@tutanota.com>2023-02-16 11:09:53 -0700
commitcbd51a8c149d3de80907540cbfda4976337124b6 (patch)
treea4e1d28bef14020eba14bacf6d2335a2c8fc960c
parent9426460adfb7f41b5a05ae925b8cab7f81b7e6f8 (diff)
downloaddwlb-cbd51a8c149d3de80907540cbfda4976337124b6.tar.gz
add ability to disable status commands
-rw-r--r--README.md2
-rw-r--r--config.def.h3
-rw-r--r--dwlb.c12
3 files changed, 13 insertions, 4 deletions
diff --git a/README.md b/README.md
index 2674d84..be73766 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ dwl -s 'dwlb -font "monospace:size=16"'
Command options send instructions to existing instances of dwlb. All commands take at least one argument to specify a bar on which to operate. This may be zxdg_output_v1 name, "all" to affect all outputs, or "selected" for the current output.
### Status Text
-The `-status` command is used to write status text. The text may contain in-line color commands in the following format: `^fg/bg(HEXCOLOR)`. For example, `^fg(ff0000)` would set the foreground red. Colors can be reset by omitting the hex value. `^^` represents a single `^` character.
+The `-status` command is used to write status text. The text may contain in-line color commands in the following format: `^fg/bg(HEXCOLOR)`. For example, `^fg(ff0000)` would set the foreground red. Colors can be reset by omitting the hex value. `^^` represents a single `^` character. Color command functionality can be disabled with `-no-status-commands`.
## Other Options
Run `dwlb -h` for a full list of options.
diff --git a/config.def.h b/config.def.h
index 47332c1..b641618 100644
--- a/config.def.h
+++ b/config.def.h
@@ -21,3 +21,6 @@ static pixman_color_t urgent_bg_color = { .red = 0xeeee, .green = 0xeeee, .blue
// vertical pixel padding above and below text
static uint32_t vertical_padding = 1;
+
+// allow in-line color commands in status text
+static bool status_commands = true;
diff --git a/dwlb.c b/dwlb.c
index 2bf9751..2f3f4be 100644
--- a/dwlb.c
+++ b/dwlb.c
@@ -56,12 +56,14 @@
#define USAGE \
"usage: dwlb [OPTIONS]\n" \
"Bar Config\n" \
- " -hide-vacant-tags do not display empty and inactive tags\n" \
- " -no-hide-vacant-tags display empty and inactive tags\n" \
" -hidden bars will initially be hidden\n" \
" -no-hidden bars will not initially be hidden\n" \
" -bottom bars will initially be drawn at the bottom\n" \
" -no-bottom bars will initially be drawn at the top\n" \
+ " -hide-vacant-tags do not display empty and inactive tags\n" \
+ " -no-hide-vacant-tags display empty and inactive tags\n" \
+ " -status-commands enable in-line commands in status text\n" \
+ " -no-status-commands disable in-line commands in status text\n" \
" -font [FONT] specify a font\n" \
" -tags [FIRST TAG]...[LAST TAG] specify custom tag names\n" \
" -vertical-padding [PIXELS] specify vertical pixel padding above and below text\n" \
@@ -425,7 +427,7 @@ draw_frame(Bar *b)
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, &inactive_fg_color, &inactive_bg_color,
- b->width, b->height, b->textpadding, true);
+ b->width, b->height, b->textpadding, status_commands);
xpos_left = draw_text(b->title, xpos_left, ypos, foreground, background,
b->selmon ? &active_fg_color : &inactive_fg_color,
@@ -1047,6 +1049,10 @@ main(int argc, char **argv)
hidden = true;
} else if (!strcmp(argv[i], "-no-hidden")) {
hidden = false;
+ } else if (!strcmp(argv[i], "-status-commands")) {
+ status_commands = true;
+ } else if (!strcmp(argv[i], "-no-status-commands")) {
+ status_commands = false;
} else if (!strcmp(argv[i], "-font")) {
if (++i >= argc)
DIE("Option -font requires an argument");