docs(README): added link to my dotfiles
docs(README): added section on async and clicable blocks
fix(block): fix empty output check
My async version of dwmblocks, using XCB
Edit config.mk
to match your local setup (dwmb is installed under /usr/local
by default).
Afterward run the following command to build and install dwmb (if necessary as root):
make clean install
Add the following line to your sxrc
or .xinitrc
:
dwmb &
To configure dwmb edit config.h
and (re)compile the source code.
static Block blocks[] = {
{.command = "printf \"Hello World!\"", .interval = 0, .signal = -1},
{.command = "date +%T", .interval = 1, .signal = -1},
{.command = "date +%s", .interval = 0, .signal = 0},
};
Each block has the following structure:
/bin/sh -c
.
Ensure that the command always outputs a newline character \n
at the end.0
to disable updating on time.0
and RTMAX - RTMIN
(displayed at start).
Use -1
to prevent updating on signal / click.The main drawback of dwmblocks is that blocks are executed synchronously, meaning one after the other. This can cause a noticeable delay with slow or many blocks.
dwmb creates separate processes for each block execution and updates the status as those processes finish execution. Meaning that slow blocks will not slow down dwmb.
First apply the statuscmd patch to dwm.
Next assign the block in config.h
with a signal number greater than 0
:
static Block blocks[] = {
{.command = "sb-test", .interval = 0, .signal = 1},
}
Finally modify the shell script itself to support button clicks:
For example, with the shell script sb-test
in PATH:
#!/bin/sh
# Start the output with the signal number as a raw byte
printf '\01' # In this case signal 1
# Handle button clicks
case $BUTTON in
1) printf 'Left click';;
2) printf 'Middle click';;
3) printf 'Right click';;
# The default case will displayed when the block is updated on time, which with
# interval 0 will only happen at the start or on SIGUSR signals.
*) printf 'Test';;
esac
# End the output with a newline character
printf '\n'
See my dotfiles for more status bar scripts.