Permalink
Browse files

add TurnOffScreen plasmoid

  • Loading branch information...
1 parent f1cda9b commit 66b41daa47f5596a980645c87a413f98c7331bf2 @grissiom committed Apr 17, 2009
View
@@ -0,0 +1,23 @@
+.PHONY:all install uninstall reinstall view tarball
+
+PRONAME=TurnOffScreen
+
+all: install
+tarball: $(PRONAME).zip
+
+install: ${PRONAME}.zip
+ plasmapkg -i ${PRONAME}.zip
+
+uninstall:
+ plasmapkg -r ${PRONAME}
+
+reinstall: uninstall install
+
+$(PRONAME).zip: metadata.desktop contents/code/main.py contents/code/gui.py
+ zip -r ${PRONAME}.zip . -x *~ contents/code/*~ .* ${PRONAME}.zip
+
+contents/code/gui.py: contents/code/gui.qrc
+ pyrcc4 $^ > $@
+
+view:
+ plasmoidviewer ${PRONAME}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,2 @@
+# let make to generate it
+gui.py
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource>
+ <file>blank-screen.png</file>
+ </qresource>
+</RCC>
@@ -0,0 +1,45 @@
+# Written by Grissiom chaos.proton@gmail.com
+
+from PyQt4.QtCore import SIGNAL
+from PyQt4.QtGui import QGraphicsLinearLayout, QIcon
+
+from PyKDE4.plasma import Plasma
+from PyKDE4 import plasmascript
+from PyKDE4.kdeui import KIcon, KGlobalSettings
+
+import dbus
+
+import gui
+
+class TurnOffScreen(plasmascript.Applet):
+ def __init__(self, parent, args = None):
+ plasmascript.Applet.__init__(self, parent)
+
+ def init(self):
+ #TODO: have a configuration interface to set keybroad shortcut
+ self.setHasConfigurationInterface(False)
+ self.setAspectRatioMode(Plasma.ConstrainedSquare)
+ self.setBackgroundHints(self.NoBackground)
+
+ self.sessionBus = dbus.SessionBus()
+ self.powerdevil = self.sessionBus.get_object('org.freedesktop.PowerManagement',
+ '/modules/powerdevil')
+
+ self.icon= Plasma.IconWidget(KIcon(':blank-screen.png'), '', self.applet)
+ if KGlobalSettings.singleClick():
+ self.connect(self.icon, SIGNAL('clicked()'), self.turn_off_screen)
+ else:
+ self.connect(self.icon, SIGNAL('doubleClicked()'), self.turn_off_screen)
+
+ self.layout = QGraphicsLinearLayout(self.applet)
+ self.layout.setContentsMargins(0, 0, 0, 0)
+ self.layout.setSpacing(0)
+ self.layout.addItem(self.icon)
+ self.setLayout(self.layout)
+ self.resize(25, 25)
+
+ def turn_off_screen(self):
+ self.powerdevil.turnOffScreen(dbus_interface='org.kde.PowerDevil')
+
+def CreateApplet(p):
+ return TurnOffScreen(p)
@@ -0,0 +1,17 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=TurnOffScreen
+Type=Service
+ServiceTypes=Plasma/Applet
+Icon=blank-screen.png
+X-Plasma-API=python
+X-Plasma-MainScript=code/main.py
+X-KDE-PluginInfo-Author=Grissiom
+X-KDE-PluginInfo-Email=chaos.proton@gmail.com
+X-KDE-PluginInfo-Name=TurnOffScreen
+X-KDE-PluginInfo-Version=0.01
+X-KDE-PluginInfo-Website=
+X-KDE-PluginInfo-Category=
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true

0 comments on commit 66b41da

Please sign in to comment.