Skip to content

IAKOBVS/dwmblocks-fast

 
 

Repository files navigation

dwmblocks-fast

A modular status bar for window managers written in C (fork of dwmblocks).

Alt text

Features

  • Blocks are implemented as C functions or shell scripts.
  • Only updates the statusbar when no change has occured.
  • Improved input validation and error handling for signals.
  • Monitors CPU and Nvidia GPU temperature, usage, VRAM usage, and power usage.
  • Avoids using printf and scanf-like functions, which avoids the runtime overhead of format parsing.
  • Sorts blocks according to their intervals and signals, while maintaining the original print order, which improves branch prediction and cache locality.

Installation

Arch Linux

$ git clone https://aur.archlinux.org/packages/dwmblocks-fast-git
$ cd dwmblocks-fast-git
$ makepkg --nobuild --nodeps

Folow the additional instructions from makepkg. Optionally, manually configure config.h, blocks.h, and config.mk.

$ cd src/dwmblocks-fast/src

And return to the directory of the PKGBUILD.

$ cd ../../..
$ makepkg -si -f

Or for a custom configuration:

$ DWMBLOCKS_FAST_OPTIONS='disable-some-library' makepkg -si -f

Building

Install the dependencies with your package manager. These can be excluded with make config.

$ make config

Follow the additional instructions from make.

$ cd src

Optionally, manually configure config.h, blocks.h, and config.mk.

$ cd ..
$ make
$ sudo make install

Dependencies

  • alsa-lib: audio monitoring
  • cuda: GPU temperature monitoring with NVML
  • libx11: printing to the status bar

Optional dependencies

  • dwm: window manager
  • gst-plugins-base-libs: sound notifications
  • dunst: popup notifications
  • pamixer: audio control
  • procps: send signals with pkill

Usage

xinitrc (for window managers that use WM_NAME)

dwmblocks-fast >>/tmp/dwmblocks-fast.log 2>>/tmp/dwmblocks-fast.log &

Print to stdout (for other window managers that read stdin)

dwmblocks -p # | some_window_manager

Modifying blocks

Adding a shell script

src/blocks.h

#define SIG_SH 11
static struct Block g_blocks[] = {
    /* Update_interval   Signal    Label    Function        Command*/
    { 0,                 SIG_SH,   "",      b_write_shell,  "my_shell_script" },
}

Adding a C function

src/blocks.h

static struct Block g_blocks[] = {
    /* Update_interval   Signal    Label    Function    Command*/
    { 2,                 0,        "",      write_my,   NULL },
}

src/blocks.h

static char *
write_my(char *dst, unsigned int dst_len, const char *unused, unsigned int *interval)
{
    /* Do something, output to dst. */
    return dst;
}

Triggering an update

SIG_SH=11
pkill -RTMIN+"$SIG_SH" dwmblocks-fast

Configuration

To enable or disable certain features or libraries, comment them out in the config.h and config.mk. For example, to disable NVML:

Automatic

Some features can be configured automatically with make (which is useful for automation).

$ make config # prints the available options

For example, to exclude CUDA from the dependencies:

$ make disable-cuda

Manual

# NVML (comment to disable)
# NVMLLIB = /opt/cuda/lib64
# LDFLAGS += -L$(NVMLLIB) -lnvidia-ml

config.mk

# NVML (comment to disable)
# NVMLLIB = /opt/cuda/lib64
# LDFLAGS += -L$(NVMLLIB) -lnvidia-ml

config.h

/* Monitor Nvidia GPU, requires CUDA. Comment to disable. */
/* #define USE_CUDA 1 */

About

A modular status bar for window managers written in C

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C 91.2%
  • Makefile 5.3%
  • Shell 3.5%