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

https://github.com/erffy/zig-waybar-contrib

โœจ Lightweight Waybar modules built with Zig
https://github.com/erffy/zig-waybar-contrib

sway waybar waybar-contrib waybar-module zig ziglang zls

Last synced: 10 months ago
JSON representation

โœจ Lightweight Waybar modules built with Zig

Awesome Lists containing this project

README

          

> [!IMPORTANT]
> This project is in active development. As I'm learning Zig, updates may take time. Your contributions, feedback, and patience are greatly appreciated! ๐Ÿš€

## zig-waybar-contrib

**High-performance Waybar modules written in Zig for efficient system monitoring**

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://gnu.org/licenses/gpl-3.0)
[![Zig](https://img.shields.io/badge/Zig-0.14+-orange.svg)](https://ziglang.org/)
[![Waybar](https://img.shields.io/badge/Waybar-Compatible-green.svg)](https://github.com/Alexays/Waybar)

### Overview

`zig-waybar-contrib` is a collection of lightweight, blazingly fast Waybar modules built with Zig. These modules are designed to provide accurate system monitoring with minimal resource usage, taking advantage of Zig's performance characteristics and memory safety.

### Why Zig?

- **Zero-cost abstractions** - Runtime performance without sacrificing code clarity
- **Compile-time safety** - Catch errors before they reach production
- **Small binaries** - Minimal overhead for system monitoring
- **Fast compilation** - Quick iteration during development

### Features

- โšก **Ultra-fast execution** - Optimized with `ReleaseFast` + LTO + LLVM
- ๐Ÿ”’ **Memory safe** - No buffer overflows or memory leaks
- ๐Ÿงฉ **Modular design** - Include only what you need
- ๐Ÿ“Š **Real-time data** - Accurate, up-to-date system metrics
- ๐ŸŽฏ **Waybar native** - JSON output format, seamless integration
- ๐Ÿชถ **Lightweight** - Minimal system dependencies

### Available Modules

All modules output single-line JSON compatible with Waybar's `custom` module interface.

| Module | Description | Status | Dependencies | Platforms | Signal |
|-------------|--------------------------------|--------------|------------------------------------|-----------------------|----------|
| **Updates** | System package update tracker | โœ… Ready | `fakeroot` | Arch Linux | 10 |
| **GPU** | GPU usage, temperature, memory | โœ… Ready | `rocm-smi-lib`, `amdsmi` or `cuda` | AMD RX Series, NVIDIA | 11 |
| **Memory** | RAM usage and statistics | โœ… Ready | None | Linux | 12 |
| **Ping** | Network latency monitoring | โœ… Ready | None | Linux | 13 |

### Screenshots

#### Updates
![Updates Module](assets/updates.png)

#### GPU
![GPU Module](assets/gpu.png)

#### Memory
![Memory Module](assets/memory.png)

#### Ping
![Ping Module](assets/ping.png)

## Installation

### Quick Installation

#### [From AUR (Recommended)](https://aur.archlinux.org/packages/zig-waybar-contrib)

You can easily install the latest version of **zig-waybar-contrib** from the Arch User Repository (AUR).
This package provides pre-built binaries as `waybar-module-X-bin`.

Use your preferred AUR helper:

```bash
# Using paru
paru -S zig-waybar-contrib

# Using yay
yay -S zig-waybar-contrib
```

### Build from Source

**Requirements:**
- Zig: 0.14.0+
- Git
- rocm-smi-lib, amdsmi or cuda (for gpu module, optional)

```bash
# Clone the repository
git clone https://github.com/erffy/zig-waybar-contrib.git && cd zig-waybar-contrib

# Build all modules
zig build

# Install to system
sudo cp zig-out/bin/* /usr/local/bin/
```

### Configuration

#### Basic Waybar Setup

Add to your Waybar configuration (`~/.config/waybar/config.jsonc`):

```jsonc
{
// Load default module configurations from zig-waybar-contrib
"include": [
"/etc/zig-waybar-contrib/config.jsonc"
],

// Display these modules on the right side of the Waybar
"modules-right": [
"custom/updates#zwc",
"custom/gpu#zwc",
"custom/memory#zwc",
"custom/ping#zwc"
],

// ๐Ÿ› ๏ธ Custom modules configuration
"custom/updates#zwc": {
"exec": "/usr/bin/waybar-module-updates-bin",
"return-type": "json",
"interval": 0,
"signal": 10,
"escape": true
},

"custom/gpu#zwc": {
"exec": "/usr/bin/waybar-module-gpu-bin",
"return-type": "json",
"interval": 0,
"signal": 11
},

"custom/memory#zwc": {
"exec": "/usr/bin/waybar-module-memory-bin",
"return-type": "json",
"interval": 0,
"signal": 12
},

"custom/ping#zwc": {
"exec": "/usr/bin/waybar-module-ping-bin",
"return-type": "json",
"interval": 0,
"signal": 13
}
}
```

### Development

#### Project Structure

```
zig-waybar-contrib/
โ”‚
โ”œโ”€โ”€ README.md # Project overview, installation, and usage instructions
โ”œโ”€โ”€ CHANGELOG.md # Version history with detailed changes per release
โ”œโ”€โ”€ LICENSE # Project license (GPL-3.0-only)
โ”œโ”€โ”€ config.waybar.jsonc # Example Waybar module configuration (JSONC format)
โ”œโ”€โ”€ .gitignore # Git exclusions for build artifacts, cache files, etc.
โ”‚
โ”œโ”€โ”€ build.zig # Zig build script for compiling all modules
โ”œโ”€โ”€ build.zig.zon # Zig package and dependency declaration (Zon format)
โ”‚
โ”œโ”€โ”€ tests/ # Test files
โ”‚
โ”œโ”€โ”€ src/ # Source code
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ utils/ # Shared utility modules
โ”‚ โ”‚ โ”œโ”€โ”€ mod.zig # Module loader and common interfaces
โ”‚ โ”‚ โ”œโ”€โ”€ waybar.zig # Waybar signal sender (e.g., USR1/USR2 signaling)
โ”‚ โ”‚ โ””โ”€โ”€ format.zig # Byte/usage formatting helpers (e.g., human-readable memory)
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ gpu/ # GPU statistics and backend integration
โ”‚ โ”‚ โ”œโ”€โ”€ gpu.zig # Unified GPU module (auto-selects backend at compile time)
โ”‚ โ”‚ โ””โ”€โ”€ backend/ # Individual backend implementations
โ”‚ โ”‚ โ”œโ”€โ”€ amdsmi.zig # AMD SMI interface (ROCm 5.x+)
โ”‚ โ”‚ โ”œโ”€โ”€ rocmsmi.zig # Legacy ROCm SMI interface
โ”‚ โ”‚ โ””โ”€โ”€ nvml.zig # NVIDIA GPU interface (via NVML/CUDA)
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ memory.zig # Module for tracking and displaying memory usage
โ”‚ โ”œโ”€โ”€ ping.zig # Module for displaying ping/latency to a target host
โ”‚ โ””โ”€โ”€ updates.zig # Module for checking for system/package updates
โ”‚
โ””โ”€โ”€ assets/ # Images, screenshots, and other media assets
```

### Contributing

Contributions are welcome! Here's how you can help:

#### Code Contributions
- ๐Ÿ› **Bug Fixes** - Help squash issues
- โšก **Performance Improvements** - Make modules even faster
- ๐Ÿงฉ **New Modules** - Add support for more system metrics
- ๐ŸŽจ **Code Quality** - Improve readability and maintainability

#### Other Ways to Help
- ๐Ÿ“– **Documentation** - Improve guides and examples
- ๐Ÿงช **Testing** - Report bugs and compatibility issues
- ๐Ÿ’ก **Feature Requests** - Suggest new modules or improvements
- ๐ŸŽจ **Themes** - Share your Waybar styling configs

#### Development Workflow

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-module`
3. Make your changes and test thoroughly
4. Follow Zig style conventions: `zig fmt src/`
5. Add tests if applicable
6. Submit a pull request with a clear description

### Roadmap

- [ ] Implement configuration support

### License

This project is licensed under the **GNU General Public License v3.0**. See [LICENSE](./LICENSE) for details.

### Acknowledgments

- **Zig Team** - For creating an amazing systems programming language
- **Waybar Contributors** - For the excellent status bar that makes this possible
- **Community** - For feedback, bug reports, and contributions

---

**Made with โค๏ธ by Me**

*Star โญ this repo if you find it useful!*