minor fix and update README for status buttons

This commit is contained in:
kolunmi 2023-02-19 11:06:31 -07:00
parent d25242c299
commit 2710f3428d
2 changed files with 21 additions and 1 deletions

View File

@ -22,7 +22,17 @@ 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, "selected" for the current output, or "first" for the first output in the internal list. 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, "selected" for the current output, or "first" for the first output in the internal list.
### 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. Color command functionality can be disabled with `-no-status-commands`. The `-status` command is used to write status text. The text may contain in-line commands in the following format: `^cmd(argument)`:
| Command | Description |
|---------------------|-----------------------------------------------------------------------------|
| `^fg(HEXCOLOR)` | Sets foreground color to `HEXCOLOR`. |
| `^bg(HEXCOLOR)` | Sets background color to `HEXCOLOR`. |
| `^lm(SHELLCOMMAND)` | Begins or terminates left mouse button region with action `SHELLCOMMAND`. |
| `^mm(SHELLCOMMAND)` | Begins or terminates middle mouse button region with action `SHELLCOMMAND`. |
| `^rm(SHELLCOMMAND)` | Begins or terminates right mouse button region with action `SHELLCOMMAND`. |
A color command with no argument reverts to the default value. `^^` represents a single `^` character. Status commands 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.

10
dwlb.c
View File

@ -1096,6 +1096,14 @@ set_status(Bar *bar, char *text)
bar->status[str_pos++] = *p; bar->status[str_pos++] = *p;
utf8decode(&state, &codepoint, *p); utf8decode(&state, &codepoint, *p);
} }
if (left_button)
left_button->end = bar->status + str_pos;
if (middle_button)
middle_button->end = bar->status + str_pos;
if (right_button)
right_button->end = bar->status + str_pos;
bar->status[str_pos] = '\0'; bar->status[str_pos] = '\0';
} else { } else {
snprintf(bar->status, sizeof bar->status, "%s", text); snprintf(bar->status, sizeof bar->status, "%s", text);
@ -1498,6 +1506,8 @@ main(int argc, char **argv)
/* Clean everything up */ /* Clean everything up */
close(sock_fd); close(sock_fd);
unlink(socketpath); unlink(socketpath);
free(stdinbuf);
zwlr_layer_shell_v1_destroy(layer_shell); zwlr_layer_shell_v1_destroy(layer_shell);
zxdg_output_manager_v1_destroy(output_manager); zxdg_output_manager_v1_destroy(output_manager);