An open API service indexing awesome lists of open source software.

https://github.com/crazyoptimist/mblocks

dwm blocks written in rust
https://github.com/crazyoptimist/mblocks

Last synced: 7 months ago
JSON representation

dwm blocks written in rust

Awesome Lists containing this project

README

          

# mblocks

This program is a multi-threaded memory-safe status monitor written in Rust.
It updates the status only when there is a change.

## Example screenshots

![example](./screenshots/screenshot_1.png)

## Installation

Clone the repository

Configure the status blocks by editing `src/config.rs`.

Run the install command.

```bash
make clean install
```

Add `mblocks &` to your `~/.xinitrc` or another shell script that will be run on boot.

## Configuration

The status monitor can be configured directly in the source `src/config.rs`.

Status blocks are defined in the `BLOCKS` vector.
Each block has a kind, executes a command, and has a prefix and a suffix for formatting.

There are 4 kinds of blocks:

- Once: blocks labeled with this kind are executed once at the start of the program.
- Periodic(N): blocks of this type are executed every N seconds.
- Signal(S): these blocks are executed when the signal S is sent to the mblocks process.
To send a signal, you can use `kill -$((34 + S)) $(pidof mblocks)` where `S` is the argument given to Signal, and it should not exceed 15 (1 <= S <= 15).
This means that you can define at most 15 Signal blocks, which is large enough.
- PeriodicOrSignal(N, S): the update of the block is made every N seconds or at the reception of the signal S.

The `command` attribute corresponds to the command to be executed and can be one of the following:

- Shell(COMMAND): this executes the shell command given as arguments (e.g. ` Shell(&["date", "+%a, %b %d %Y"])`). Note the `&` preceding the array of arguments!
- Function(F): this executes the Rust function F given as argument. These latter can be placed in the directory `src/blocks/`. Check out the example functions.

The configuration file also defines the variable `SEPARATOR` that specifies the delimiter between blocks, and which could be any string.
The generated status starts with the value of the variable `PREFIX` and ends with the value of the variable `SUFFIX`.

## Misc.

- If an empty string `""` is returned by a block execution, then the corresponding block will not be displayed.
- If the exit status of a `Shell` command is non-zero, then `failed` will be shown in the status (in the corresponding block).
- If a `Function` command returns `None`, then `failed` will be shown in the status (in the corresponding block).
- mblocks is memory-safe; it is validated with valgrind. The memory leaks shown by valgrind are false positives related to the signal-hook crate.

## Credits

Forked from [this repo](https://gitlab.com/mhdy/mblocks.git).

## License

MIT