Created
August 9, 2023 07:31
-
-
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.
This file contains 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
#!/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