Monday, 30 September 2013

VPN Network Connection notifications/icons

VPN Network Connection notifications/icons

This question is like Is it possible to add a notification message when a
VPN gets connected? . The python script in the answer there (see below)
works OK on 13.04, but it only notifies on making new connections, not
when a VPN connection is disconnected, which is much more important since
it can happen at any time.
Can someone please tweak the script for disconnections?
Alternatively, where is the network connection (for VPN) tray icon held in
the file system, so I can change it - the miniature padlock is so tiny it
is barely visible. Reversed foreground/background colours would be better.
====
import gtk
import pynotify
import dbus
from dbus.mainloop.glib import DBusGMainLoop
def vpn_connection_handler(*args, **keywords):
state = args[0].get('State',0)
if state == 2:
n = pynotify.Notification ("VPN", "Connection established")
n.show()
pynotify.init ("icon-summary-body")
dbus_loop = DBusGMainLoop()
system_bus = dbus.SystemBus(mainloop=dbus_loop)
system_bus.add_signal_receiver(vpn_connection_handler,
dbus_interface="org.freedesktop.NetworkManager.VPN.Connection",
signal_name="PropertiesChanged")
gtk.gdk.threads_init()
gtk.main()
=====

No comments:

Post a Comment