Skip to content

Instantly share code, notes, and snippets.

@Delt-A
Created August 9, 2023 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Delt-A/096c609b633ff7adf128d977d13e5ebe to your computer and use it in GitHub Desktop.
Save Delt-A/096c609b633ff7adf128d977d13e5ebe to your computer and use it in GitHub Desktop.
Show 2 VPN IP on taskbar if there are 2 VPN connections.
#!/bin/sh
interface1="$(ip tuntap show | cut -d : -f1 | sed -n '1p')"
interface2="$(ip tuntap show | cut -d : -f1 | sed -n '2p')"
ip1="$(ip a s "${interface1}" 2>/dev/null \
| grep -o -P '(?<=inet )[0-9]{1,3}(\.[0-9]{1,3}){3}')"
ip2="$(ip a s "${interface2}" 2>/dev/null \
| grep -o -P '(?<=inet )[0-9]{1,3}(\.[0-9]{1,3}){3}')"
if [ "${ip1}" != "" ] && [ "${ip2}" != "" ]; then
printf "<icon>network-vpn-symbolic</icon>"
printf "<txt>VPN1: ${ip1} VPN2: ${ip2}</txt>"
printf "<tool>VPN IP</tool>"
elif [ "${ip1}" != "" ]; then
printf "<icon>network-vpn-symbolic</icon>"
printf "<txt>VPN: ${ip1} </txt>"
printf "<tool>VPN IP</tool>"
else
printf "<txt></txt>"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment