| Crates.io | wg-toggle |
| lib.rs | wg-toggle |
| version | 1.0.0 |
| created_at | 2025-05-15 10:09:19.663231+00 |
| updated_at | 2025-05-15 10:09:19.663231+00 |
| description | Toggle Wireguard connection state |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1674770 |
| size | 8,432 |
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:
/tmp/wg-current)NetworkManagernmcli (import .conf files with nmcli connection import)waybar with custom module supportgit clone https://github.com/yourusername/wg-waybar-toggle
cd wg-waybar-toggle
cargo build --release
$PATH:cp target/release/wg-toggle ~/.local/vin/
"custom/wg": {
"exec": "~/.local/bin/wg-toggle --status",
"return-type": "json",
"interval": 10,
"on-click": "~/.local/bin/wg-toggle",
"on-click-right": "~/.local/bin/wg-toggle next",
"on-scroll-up": "~/.local/bin/wg-toggle previous",
"on-scroll-down": "~/.local/bin/wg-toggle next",
"tooltip": true
}
#custom-wg.active {
background-color: #a6e3a1;
color: #1e1e2e;
}
#custom-wg.inactive {
background-color: #45475a;
color: #cdd6f4;
}
| 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 |
Use nmcli to import .conf files:
nmcli connection import type wireguard file wg-home.conf
nmcli connection import type wireguard file wg-work.conf
Names must be valid Linux interface names (<=15 characters, no spaces).
To test the output:
~/.local/bin/wg-toggle --status
~/.local/bin/wg-toggle
~/.local/bin/wg-toggle next
MIT
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:
rustfmt