Update of /cvsroot/freevo/freevo/src/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18939
Modified Files: usb.py Log Message: add hotplugging Index: usb.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/plugins/usb.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** usb.py 4 Oct 2003 18:37:29 -0000 1.5 --- usb.py 28 Feb 2004 11:28:56 -0000 1.6 *************** *** 11,14 **** --- 11,17 ---- # ----------------------------------------------------------------------- # $Log$ + # Revision 1.6 2004/02/28 11:28:56 dischi + # add hotplugging + # # Revision 1.5 2003/10/04 18:37:29 dischi # i18n changes and True/False usage *************** *** 43,49 **** --- 46,56 ---- #endif + import os + + import config import plugin import util import rc + from gui import PopupBox class PluginInterface(plugin.DaemonPlugin): *************** *** 52,55 **** --- 59,73 ---- plugin if you use mainmenu plugins for special usb devices like camera.py. + + You can also set USB_HOTPLUG in your local_config.py to call + an external program when a device is added. USB_HOTPLUG is a + list with actions. Each action is also a list of device, message + and program to call. Limitation: this works only when Freevo shows + the menu and is not running a video. + + Example: + call pilot-xfer when a pda with the id 082d:0100 is pluged in: + USB_HOTPLUG = [ ('082d:0100', 'Synchronizing', + '/usr/bin/pilot-xfer -t -u /local/visor/current') ] """ def __init__(self): *************** *** 58,66 **** self.poll_interval = 10 def poll(self, menuw=None, arg=None): """ poll to check for devices """ - changes = False --- 76,88 ---- self.poll_interval = 10 + + def config(self): + return [( 'USB_HOTPLUG', [], 'action list when a devices comes up' )] + + def poll(self, menuw=None, arg=None): """ poll to check for devices """ changes = False *************** *** 70,76 **** self.devices.remove(d) except ValueError: - changes = True print 'usb.py: new device %s' %d ! for d in self.devices: changes = True --- 92,106 ---- self.devices.remove(d) except ValueError: print 'usb.py: new device %s' %d ! for device, message, action in config.USB_HOTPLUG: ! if d == device: ! pop = PopupBox(text=message) ! pop.show() ! os.system(action) ! pop.destroy() ! break ! else: ! changes = True ! for d in self.devices: changes = True ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Freevo-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freevo-cvslog