Commits

Peter Bui committed d953809

udiskie.mount: use PyNotify to send notification when mounting device

  • Participants
  • Parent commits 7acd21e

Comments (0)

Files changed (1)

File udiskie/mount.py

 
 import udiskie.device
 
+import os
+
+from pynotify import init as NotifyInitialize
+from pynotify import Notification
+
 class DeviceState:
     def __init__(self, mounted):
         self.mounted = mounted
             try:
                 device.mount(filesystem, options)
                 self.log.info('mounted device %s' % (device,))
+		Notification('Device mounted',
+                             '%s mounted on %s' % (os.path.basename(str(device)),
+                             	                   ', '.join(device.mount_paths())),
+                             'drive-removable-media').show()
             except dbus.exceptions.DBusException, dbus_err:
                 self.log.error('failed to mount device %s: %s' % (device,
                                                                   dbus_err))
         log_level = logging.DEBUG
     logging.basicConfig(level=log_level, format='%(message)s')
 
+    NotifyInitialize('udiskie.mount')
+
     mounter = AutoMounter()
     mounter.mount_present_devices()
     return gobject.MainLoop().run()