wg-toggle-1.0.0 is not a library.
๐ Waybar WireGuard VPN Toggle (Rust)
A lightweight, fast, and minimal Rust-based utility for managing WireGuard VPNs via NetworkManager (nmcli). Built for integration into Waybar as a custom module, it allows users to:
- Toggle VPN on/off with a click
- Rotate between configured VPNs via scroll or right-click
- Display current VPN status in Waybar
- Output proper JSON for color and icon styling
๐ฆ Features
- ๐ Written in Rust for speed and safety
- ๐ง Remembers current VPN between reboots (
/tmp/wg-current) - ๐ฑ๏ธ Scroll or right-click to cycle through VPN configs
- ๐จ Emits Waybar-compatible JSON for visual theming
๐ Dependencies
NetworkManager- WireGuard support via
nmcli(import.conffiles withnmcli connection import) waybarwithcustommodule support
๐ง Installation
1. Clone and build
2. Move binary to somehwere in your $PATH:
๐ผ๏ธ Waybar Integration
Example module config:
"custom/wg":
Example CSS:
}
}
โ๏ธ Behavior
| Action | Result |
|---|---|
| Left Click | Toggle current VPN on/off |
| Scroll Up | Switch to previous VPN config |
| Scroll Down | Switch to next VPN config |
| Right Click | Switch to next VPN config |
| Auto-refresh | Show current VPN status |
๐ VPN Configuration
Use nmcli to import .conf files:
Names must be valid Linux interface names (<=15 characters, no spaces).
๐งช Debugging
To test the output:
๐ชช License
MIT
๐ค Contributing
Pull requests and suggestions are very welcome!
If you'd like to improve the script, support more VPN managers, or enhance the Waybar integration, feel free to open an issue or PR.
Please ensure any code contributions:
- Are formatted with
rustfmt - Include basic error handling
- Preserve existing CLI behavior