
If you frequently switch between trusted and untrusted networks, manually toggling your VPN becomes...
If you frequently switch between trusted and untrusted networks, manually toggling your VPN becomes tedious fast.
This guide shows how to automatically connect or disconnect Cloudflare WARP based on your WiFi network name (SSID) using NetworkManager on Linux.
Not all networks are equal:
Instead of manually toggling WARP every time, we can hook into network state changes and automate it.
Linux systems using NetworkManager support dispatcher scripts—these are triggered automatically when network events occur (e.g., connecting to WiFi).
We leverage this to:
Make sure warp-cli is available. Then register and test:
warp-cli register
warp-cli connect
warp-cli status
Dispatcher scripts live here:
/etc/NetworkManager/dispatcher.d/
Create a new script:
sudo nano /etc/NetworkManager/dispatcher.d/99-warp-toggle
#!/bin/bash
INTERFACE="$1"
STATUS="$2"
# Trigger only when a connection is established
if [ "$STATUS" = "up" ]; then
SSID=$(iwgetid -r)
if [ "$SSID" = "home_wifi" ]; then
echo "Connecting WARP for $SSID"
warp-cli connect
elif [ "$SSID" = "office_wifi" ]; then
echo "Disconnecting WARP for $SSID"
warp-cli disconnect
else
echo "Unknown network: $SSID — no action taken"
fi
fi
sudo chmod +x /etc/NetworkManager/dispatcher.d/99-warp-toggle
Restart NetworkManager:
sudo systemctl restart NetworkManager
Or simply reconnect your WiFi.
Switch between your networks:
home_wifi → WARP should connectoffice_wifi → WARP should disconnectVerify with:
warp-cli status
iwgetid (usually part of wireless-tools)🔹 Add Logging
echo "$(date): Connected to $SSID" >> /var/log/warp-toggle.log
case "$SSID" in
"home_wifi")
warp-cli connect
;;
"office_wifi")
warp-cli disconnect
;;
*)
echo "No rule for $SSID"
;;
esac
You can invert the logic:
This approach is:
You’re essentially turning your machine into a context-aware system—reacting intelligently to its environment.
Once you get comfortable with dispatcher scripts, you can extend this pattern to:
Happy hacking 🚀
gemmaI ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...
communityHey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...
ai(yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...
aiMy laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...
githubactionsI Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...
aiI've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...
Workflows from the Neura Market marketplace related to this Perplexity resource