Created
January 10, 2014 23:05
-
-
Save ebroder/8364402 to your computer and use it in GitHub Desktop.
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/python | |
import os | |
import subprocess | |
from gi.repository import GLib, NMClient | |
def active_connections_changed(*args): | |
for sock in os.listdir(os.path.expanduser('~/.ssh/sockets')): | |
user, hostport = sock.split('@') | |
host, port = hostport.split(':') | |
subprocess.call(['ssh', '-O', 'stop', '-l', user, '-p', port, host]) | |
c = NMClient.Client.new() | |
c.connect('notify::active-connections', active_connections_changed) | |
GLib.MainLoop().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment