Author: dmeyer
Date: Tue Mar 27 20:39:46 2007
New Revision: 9404
Added:
trunk/ui/src/plugins/dpms.py
Modified:
trunk/ui/src/plugins/config.cxml
Log:
add plugin to control screen blanking via DPMS
Modified: trunk/ui/src/plugins/config.cxml
==============================================================================
--- trunk/ui/src/plugins/config.cxml (original)
+++ trunk/ui/src/plugins/config.cxml Tue Mar 27 20:39:46 2007
@@ -65,4 +65,32 @@
possible to unpack files.
</desc>
</group>
+
+ <group name="dpms" plugin="true">
+ <event name="DPMS_BLANK_SCREEN"/>
+ <desc>
+ This plugin turns off DPMS (Energy Star) and screen blanking when
+ using Freevo with X. The program "xset" needs to be installed. On
+ Freevo shutdown the plugin turns on DPMS again.
+ The plugin defines an event called DPMS_BLANK_SCREEN which can be
+ used to turn off the monitor or tv and keep Freevo running. Every
+ key pressed after that will turn on the monitor again. The key
+ itself is also processed by Freevo, so e.g. pressing SELECT while
+ the screen is blank would result in SELECT being handled by
+ Freevo. The only exception is the DPMS_BLANK_SCREEN event itself.
+ The event can be mapped to any key, see the documentation about the
+ input selction itself. The following will send the event when
+ pressing 'b' on the keyboard or sending DPMS_BLANK_SCREEN from the
+ lircrc:
+ input.keyboardmap[B] = DPMS_BLANK_SCREEN
+ input.eventmap[global][DPMS_BLANK_SCREEN] = DPMS_BLANK_SCREEN
+ </desc>
+ <var name="timeout" default="0">
+ <desc>
+ If timeout is greater zero the screen will blank after
+ timeout minutes when in Freevo shows the menu.
+ </desc>
+ </var>
+ </group>
+
</config>
Added: trunk/ui/src/plugins/dpms.py
==============================================================================
--- (empty file)
+++ trunk/ui/src/plugins/dpms.py Tue Mar 27 20:39:46 2007
@@ -0,0 +1,115 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------
+# dpms.py - Manage DPMS settings for X displays
+# -----------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2007 Dirk Meyer, et al.
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer: Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS 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
+#
+# ----------------------------------------------------------------------- */
+
+# python imports
+import os
+
+# kaa imports
+import kaa.utils
+import kaa.notifier
+
+# freevo core imports
+from freevo.plugin import Plugin
+
+# freevo.ui imports
+from freevo.ui.config import config
+from freevo.ui.event import Event, DPMS_BLANK_SCREEN
+from freevo.ui.application import signals as app_signals
+
+
+class PluginInterface(Plugin):
+
+ def plugin_activate(self, level):
+ if not os.environ.get('DISPLAY') or not kaa.utils.which('xset'):
+ return
+ # get xset process to call
+ self.xset = kaa.notifier.Process(kaa.utils.which('xset')).start
+ self.counter = 0
+ self.is_blank = False
+ # Timer to poll and increase counter. It willbe started when the
+ # menu is shown.
+ self.timer = kaa.notifier.Timer(self.poll)
+ # register to all events
+ kaa.notifier.EventHandler(self.eventhandler).register()
+ # turn on dpms on shutdown
+ kaa.notifier.signals['shutdown'].connect(self.xset, '+dpms')
+ # register to application changes
+ app_signals['changed'].connect(self.application_changed)
+ # turn off dpms
+ self.xset('-dpms s off')
+
+
+ def poll(self):
+ """
+ Poll function called every minute to check for timeout.
+ """
+ self.counter += 1
+ if self.counter == config.plugin.dpms.timeout:
+ # timeout, force dpms and turn off the monitor
+ self.is_blank = True
+ self.xset('dpms force off')
+ # stop poll timer
+ self.timer.stop()
+
+
+ def application_changed(self, app):
+ """
+ Callback on application changes.
+ """
+ if app.get_name() == 'menu':
+ # menu is shown, start timer
+ self.timer.start(60)
+ self.counter = 0
+ else:
+ # something else is shown, stop timer
+ self.timer.stop()
+
+
+ def eventhandler(self, event):
+ """
+ Handle events from Freevo.
+ """
+ if event.source == 'user':
+ # user generated event (key/button), reset timeout counter
+ self.counter = 0
+ if self.is_blank:
+ # screen is blank right now, restore it
+ self.is_blank = False
+ self.xset('dpms force on s reset')
+ kaa.notifier.OneShotTimer(self.xset, '-dpms s off').start(1)
+ self.timer.start(60)
+ return
+
+ if event == DPMS_BLANK_SCREEN:
+ # event to turn off the monitor
+ self.is_blank = True
+ self.xset('dpms force off')
+ self.timer.stop()
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog