~jstnas/dwmb

asynchronous dwm status monitor
docs(README): added link to my dotfiles
docs(README): added section on async and clicable blocks
fix(block): fix empty output check

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~jstnas/dwmb
read/write
git@git.sr.ht:~jstnas/dwmb

You can also use your local clone with git send-email.

#dwmb - dwmblocks

My async version of dwmblocks, using XCB

#Requirements

  • C99
    • XCB headers (libxcb)

#Installation

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

#Running dwmb

Add the following line to your sxrc or .xinitrc:

dwmb &

#Configuration

To configure dwmb edit config.h and (re)compile the source code.

#Modifying blocks

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:

  • Command: Shell command to be executed using /bin/sh -c. Ensure that the command always outputs a newline character \n at the end.
  • Interval: Time in seconds between block updates. Use 0 to disable updating on time.
  • Signal: Signal to use for updating the block. Use a number between 0 and RTMAX - RTMIN (displayed at start). Use -1 to prevent updating on signal / click.

#Asynchronous block updates

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.

#Clickable blocks

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.

#References

Do not follow this link