add ability to disable status commands

This commit is contained in:
kolunmi 2023-02-16 11:09:53 -07:00
parent 9426460adf
commit cbd51a8c14
3 changed files with 13 additions and 4 deletions

View File

@ -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. 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 ### 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 ## Other Options
Run `dwlb -h` for a full list of options. Run `dwlb -h` for a full list of options.

View File

@ -21,3 +21,6 @@ static pixman_color_t urgent_bg_color = { .red = 0xeeee, .green = 0xeeee, .blue
// vertical pixel padding above and below text // vertical pixel padding above and below text
static uint32_t vertical_padding = 1; static uint32_t vertical_padding = 1;
// allow in-line color commands in status text
static bool status_commands = true;

12
dwlb.c
View File

@ -56,12 +56,14 @@
#define USAGE \ #define USAGE \
"usage: dwlb [OPTIONS]\n" \ "usage: dwlb [OPTIONS]\n" \
"Bar Config\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" \ " -hidden bars will initially be hidden\n" \
" -no-hidden bars will not initially be hidden\n" \ " -no-hidden bars will not initially be hidden\n" \
" -bottom bars will initially be drawn at the bottom\n" \ " -bottom bars will initially be drawn at the bottom\n" \
" -no-bottom bars will initially be drawn at the top\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" \ " -font [FONT] specify a font\n" \
" -tags [FIRST TAG]...[LAST TAG] specify custom tag names\n" \ " -tags [FIRST TAG]...[LAST TAG] specify custom tag names\n" \
" -vertical-padding [PIXELS] specify vertical pixel padding above and below text\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); 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, draw_text(b->status, b->width - status_width, ypos, foreground,
background, &inactive_fg_color, &inactive_bg_color, 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, xpos_left = draw_text(b->title, xpos_left, ypos, foreground, background,
b->selmon ? &active_fg_color : &inactive_fg_color, b->selmon ? &active_fg_color : &inactive_fg_color,
@ -1047,6 +1049,10 @@ main(int argc, char **argv)
hidden = true; hidden = true;
} else if (!strcmp(argv[i], "-no-hidden")) { } else if (!strcmp(argv[i], "-no-hidden")) {
hidden = false; 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")) { } else if (!strcmp(argv[i], "-font")) {
if (++i >= argc) if (++i >= argc)
DIE("Option -font requires an argument"); DIE("Option -font requires an argument");