Last active
August 29, 2015 14:13
-
-
Save rolandshoemaker/1533acdab2987fdee69a to your computer and use it in GitHub Desktop.
Am I connected to a vpn right now? (for conky)
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
#!/usr/bin/python3 | |
# am i connected to a vpn? (using nmcli) | |
import subprocess | |
vpnd = bool() | |
for l in subprocess.Popen(["nmcli", "-t", "--fields", "name,vpn", "c", "status"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].decode("utf-8").split("\n"): | |
if len(l) > 0: | |
a, b = l.split(":") | |
if b == "yes": | |
print('[92m'+a+'[0m', end="", flush=True) | |
vpnd = True | |
break | |
if not vpnd: | |
print('[91m'+"None"+'[0m', end="", flush=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment