Created
April 19, 2026 15:54
-
-
Save bplaxco/2a963314bd476185e62de404c251da0a to your computer and use it in GitHub Desktop.
Manage first NetworkManager wireguard profile based on first wifi interface actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Place at: /etc/NetworkManager/dispatcher.d/00_vpn.sh | |
| set -euo pipefail | |
| interface="$1" | |
| action="$2" | |
| wifi_interface="$(nmcli device | awk '{ if ($2 == "wifi") { print $1 }}' | head -n 1)" | |
| wireguard_profile="$(nmcli con show | awk '{ if ($3 == "wireguard") { print $2 }}' | head -n 1)" | |
| if [[ "${interface}" == "${wifi_interface}" ]] | |
| then | |
| nmcli con "${action}" "${wireguard_profile}" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment