dotfiles

commit 74ee4fcf9e466cc1834d105bf34bc36e8ba9ce53

Author: Honza Pokorny <me@honza.ca>

Add is vpn connected script

 bin/is-vpn-connected | 18 ++++++++++++++++--


diff --git a/bin/is-vpn-connected b/bin/is-vpn-connected
index d7a148a57b33db687a8697a02e858c748d849b5e..178f3c29a78402dba4bd48ee86de4980b0b1d2c8 100755
--- a/bin/is-vpn-connected
+++ b/bin/is-vpn-connected
@@ -1,8 +1,22 @@
-#!/usr/bin/env bash
+#!/usr/bin/env python
 
 # Status code:
 #
 #   0 => Connected
 #   1 => Not connected
 
-nmcli connection show --active | grep vpn
\ No newline at end of file
+import subprocess
+
+cmd = 'nmcli --terse connection show --active'
+
+def main():
+    out = subprocess.check_output(cmd.split(' '))
+    for line in out.splitlines():
+        if 'vpn' in str(line):
+            print('{"text": "VPN: up"}')
+            return
+
+    print('{"text": "VPN: down"}')
+
+
+main()