Skip to content

Instantly share code, notes, and snippets.

@rolandshoemaker
Last active August 29, 2015 14:13
Show Gist options
  • Save rolandshoemaker/1533acdab2987fdee69a to your computer and use it in GitHub Desktop.
Save rolandshoemaker/1533acdab2987fdee69a to your computer and use it in GitHub Desktop.
Am I connected to a vpn right now? (for conky)
#!/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(''+a+'', end="", flush=True)
vpnd = True
break
if not vpnd:
print(''+"None"+'', end="", flush=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment