• Stars
    star
    229
  • Rank 174,666 (Top 4 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 3 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An efficient, lean, and asynchronous status feed generator for dwm.

dwmblocks-async

A dwm status bar that has a modular, async design, so it is always responsive. Imagine i3blocks, but for dwm.

A lean config of dwmblocks-async.

Features

Additionally, this build of dwmblocks is more optimized and fixes the flickering of the status bar when scrolling.

Why dwmblocks?

In dwm, you have to set the status bar through an infinite loop, like so:

while :; do
    xsetroot -name "$(date)"
    sleep 30
done

This is inefficient when running multiple commands that need to be updated at different frequencies. For example, to display an unread mail count and a clock in the status bar:

while :; do
    xsetroot -name "$(mailCount) $(date)"
    sleep 60
done

Both are executed at the same rate, which is wasteful. Ideally, the mail counter would be updated every thirty minutes, since there's a limit to the number of requests I can make using Gmail's APIs (as a free user).

dwmblocks allows you to divide the status bar into multiple blocks, each of which can be updated at its own interval. This effectively addresses the previous issue, because the commands in a block are only executed once within that time frame.

Why dwmblocks-async?

The magic of dwmblocks-async is in the async part. Since vanilla dwmblocks executes the commands of each block sequentially, it leads to annoying freezes. In cases where one block takes several seconds to execute, like in the mail and date blocks example from above, the delay is clearly visible. Fire up a new instance of dwmblocks and you'll see!

With dwmblocks-async, the computer executes each block asynchronously (simultaneously).

Installation

Clone this repository, modify config.h appropriately, then compile the program:

git clone https://github.com/UtkarshVerma/dwmblocks-async.git
cd dwmblocks-async
vi config.h
sudo make install

Usage

To set dwmblocks-async as your status bar, you need to run it as a background process on startup. One way is to add the following to ~/.xinitrc:

# The binary of `dwmblocks-async` is named `dwmblocks`
dwmblocks &

Modifying the blocks

You can define your status bar blocks in config.c:

Block blocks[] = {
    ...
    {"volume", 0,    5},
    {"date",   1800, 1},
    ...
}

Each block has the following properties:

Property Description
Command The command you wish to execute in your block.
Update interval Time in seconds, after which you want the block to update. If 0, the block will never be updated.
Update signal Signal to be used for triggering the block. Must be a positive integer. If 0, a signal won't be set up for the block and it will be unclickable.

Apart from defining the blocks, features can be toggled through config.h:

// Maximum possible length of output from block, expressed in number of characters.
#define CMDLENGTH 50

// The status bar's delimiter that appears in between each block.
#define DELIMITER " "

// Adds a leading delimiter to the status bar, useful for powerline.
#define LEADING_DELIMITER 1

// Enable clickability for blocks. See the "Clickable blocks" section below.
#define CLICKABLE_BLOCKS 1

Signalling changes

Most status bars constantly rerun all scripts every few seconds. This is an option here, but a superior choice is to give your block a signal through which you can indicate it to update on relevant event, rather than have it rerun idly.

For example, the volume block has the update signal 5 by default. I run kill -39 $(pidof dwmblocks) alongside my volume shortcuts in dwm to only update it when relevant. Just add 34 to your signal number! You could also run pkill -RTMIN+5 dwmblocks, but it's slower.

To refresh all the blocks, run kill -10 $(pidof dwmblocks) or pkill -SIGUSR1 dwmblocks.

All blocks must have different signal numbers!

Clickable blocks

Like i3blocks, this build allows you to build in additional actions into your scripts in response to click events. You can check out my status bar scripts as references for using the $BLOCK_BUTTON variable.

To use this feature, define the CLICKABLE_BLOCKS feature macro in your config.h:

#define CLICKABLE_BLOCKS 1

Apart from that, you need dwm to be patched with statuscmd.

Credits

This work would not have been possible without Luke's build of dwmblocks and Daniel Bylinka's statuscmd patch.

More Repositories

1

hugo-dream-plus

🌈 An upgraded version of the Hugo "Dream" theme with tons of new features.
HTML
68
star
2

qemu-vfio-win10

Shell script for launching a Windows 10 guest with GPU passthrough using Looking Glass.
Shell
37
star
3

qgmail

Access the power of Gmail API through your terminal.
Go
24
star
4

dotfiles

Dotfiles of my Arch Linux setup.
Lua
21
star
5

hugo-modules

Collection of Hugo modules which I use and develop.
HTML
18
star
6

installer-scripts

💻 Bash scripts for doing installations in one go.
Shell
17
star
7

ESPer

🔋 Repository for storing files for ESPer - A DIY ESP32 Development Board
15
star
8

i3blocklets

📌 Custom scripts for i3blocks written in bash.
Shell
14
star
9

dwl-flexipatch

A dwl build with preprocessor directives to decide which patches to include during build time.
C
13
star
10

molokai.nvim

Molokai colorscheme for Neovim.
Lua
9
star
11

ecosia-darker

🌱 A dark theme for the green search engine Ecosia.
CSS
8
star
12

esp-temp

🌡️ A Mongoose OS app for sending temperature readings of ESP devices to Losant.
JavaScript
6
star
13

rswal

Rust
5
star
14

dotfiles-kde-i3

📁 My dotfiles for KDE setup with i3wm
Shell
4
star
15

st

My build of st using st-flexipatch.
C
4
star
16

dwm

My build of dwm based on dwm-flexipatch.
C
3
star
17

stm32-hal-blink-minimal

A minimal project to blink an LED on the STM32 Bliue Pill using the Make build system.
C
3
star
18

go-cli-boilerplate

Boilerplate code for developing a CLI application using Go.
Go
3
star
19

8-bit-computer

Contains programs and other stuff related to my build of Ben Eater's SAP 8-bit computer.
C++
3
star
20

LineFollower

⚡ Repository dedicated to hosting files related to a Line Follower Robot based on PIC16F84A.
C
3
star
21

stm32f7-hal

My learning journey for STM32 HAL development.
C
2
star
22

UtkarshVerma

2
star
23

atmega328p-oled-asm

An AVR assembly project for playing any video on an OLED display using ATmega328P and an SD card.
C++
2
star
24

Boggler

🔁 Repository for hosting files for "Boggler"
1
star
25

kantan-talk

A simple static solution for commenting on static websites.
TypeScript
1
star
26

fit-hpd-gsi

A C++ routine written using the ROOT framework to parse and analyze data for the HPD group at GSI.
C++
1
star
27

wiki-resources

💾 Repository dedicated to hosting wiki-resources of the other repositories.
1
star
28

avr-assembly-atmega328p

Programs I wrote for fun for ATmega328P in AVR assembly.
C++
1
star
29

8-bit-computer-spice

1
star
30

rpi4b-from-scratch

Makefile
1
star