Author: duncan
Date: Mon Dec 17 15:25:33 2007
New Revision: 10213

Log:
[ 1852190 ] Plugin for creating new events
New plug-in from Francisco Eduardo Álvarez Solano added


Added:
   branches/rel-1-7/freevo/src/plugins/newevents.py   (contents, props changed)
   branches/rel-1/freevo/src/plugins/newevents.py   (contents, props changed)
Modified:
   branches/rel-1-7/freevo/ChangeLog
   branches/rel-1/freevo/ChangeLog

Modified: branches/rel-1-7/freevo/ChangeLog
==============================================================================
--- branches/rel-1-7/freevo/ChangeLog   (original)
+++ branches/rel-1-7/freevo/ChangeLog   Mon Dec 17 15:25:33 2007
@@ -17,6 +17,7 @@
 --------------------------------
 
  * New Alsa mixer 2 plug-in (F#1832948)
+ * New user events plug-in to run commands (F#1852190)
  * New French DVD trailer grabber (F#1841775)
  * New French movie cover grabber (F#1841768)
  * New gphoto plug-in, in contrib/runtime (F#1838260)

Added: branches/rel-1-7/freevo/src/plugins/newevents.py
==============================================================================
--- (empty file)
+++ branches/rel-1-7/freevo/src/plugins/newevents.py    Mon Dec 17 15:25:33 2007
@@ -0,0 +1,84 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# Plugin for creating new events
+# -----------------------------------------------------------------------
+# $Id$
+#
+# Notes:
+# Todo:
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
+
+
+from os import system
+
+import config
+import plugin
+import rc
+from event import *
+
+
+class PluginInterface(plugin.DaemonPlugin):
+    """
+    A plugin to create and control new events, specially events associated to a
+    script. The events are configured like this:
+    (<EVENT>, <command>, [<OSD message>])
+
+    To activate it, put the following in local_conf.py:
+
+    | plugin.activate('newevents')
+    | NEW_EVENTS = [
+    |     ('MON_SWITCH_OFF', 'xset dpms force off', 'DPMS turned off'),
+    |     ('XTERM', 'xterm -fa terminal -fs 14 -bg black -fg grey &'),
+    |     ('WWW', 'firefox www.google.es/ig &')
+    | ]
+    | EVENTS['global']['q'] = Event('MON_SWITCH_OFF')
+    | EVENTS['global']['t'] = Event('XTERM')
+
+    # To map a key already in use:
+    | GLOBAL_EVENTS['WWW'] = Event('WWW')
+    | KEYMAP[key.K_w] = 'WWW'
+    """
+
+    def __init__(self):
+        plugin.DaemonPlugin.__init__(self)
+
+
+    def config(self):
+        """
+        The config information
+        """
+        return [
+            ('NEW_EVENTS', [], 'A list of events and command tuples'),
+        ]
+
+
+    def eventhandler(self, event=None, menuw=None, arg=None):
+        """
+        eventhandler to handle the new events
+        """
+        for r in config.NEW_EVENTS:
+            if event == r[0]:
+                system(r[1])
+                if len(r) > 2:
+                    rc.post_event(Event(OSD_MESSAGE, arg=r[2]))
+                return True

Modified: branches/rel-1/freevo/ChangeLog
==============================================================================
--- branches/rel-1/freevo/ChangeLog     (original)
+++ branches/rel-1/freevo/ChangeLog     Mon Dec 17 15:25:33 2007
@@ -23,6 +23,7 @@
 --------------------------------
 
  * New Alsa mixer 2 plug-in (F#1832948)
+ * New user events plug-in to run commands (F#1852190)
  * New French DVD trailer grabber (F#1841775)
  * New French movie cover grabber (F#1841768)
  * New gphoto plug-in, in contrib/runtime (F#1838260)

Added: branches/rel-1/freevo/src/plugins/newevents.py
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/plugins/newevents.py      Mon Dec 17 15:25:33 2007
@@ -0,0 +1,84 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# Plugin for creating new events
+# -----------------------------------------------------------------------
+# $Id$
+#
+# Notes:
+# Todo:
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------
+
+
+from os import system
+
+import config
+import plugin
+import rc
+from event import *
+
+
+class PluginInterface(plugin.DaemonPlugin):
+    """
+    A plugin to create and control new events, specially events associated to a
+    script. The events are configured like this:
+    (<EVENT>, <command>, [<OSD message>])
+
+    To activate it, put the following in local_conf.py:
+
+    | plugin.activate('newevents')
+    | NEW_EVENTS = [
+    |     ('MON_SWITCH_OFF', 'xset dpms force off', 'DPMS turned off'),
+    |     ('XTERM', 'xterm -fa terminal -fs 14 -bg black -fg grey &'),
+    |     ('WWW', 'firefox www.google.es/ig &')
+    | ]
+    | EVENTS['global']['q'] = Event('MON_SWITCH_OFF')
+    | EVENTS['global']['t'] = Event('XTERM')
+
+    # To map a key already in use:
+    | GLOBAL_EVENTS['WWW'] = Event('WWW')
+    | KEYMAP[key.K_w] = 'WWW'
+    """
+
+    def __init__(self):
+        plugin.DaemonPlugin.__init__(self)
+
+
+    def config(self):
+        """
+        The config information
+        """
+        return [
+            ('NEW_EVENTS', [], 'A list of events and command tuples'),
+        ]
+
+
+    def eventhandler(self, event=None, menuw=None, arg=None):
+        """
+        eventhandler to handle the new events
+        """
+        for r in config.NEW_EVENTS:
+            if event == r[0]:
+                system(r[1])
+                if len(r) > 2:
+                    rc.post_event(Event(OSD_MESSAGE, arg=r[2]))
+                return True

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to