Skip to content

Commit

Permalink
add TurnOffScreen plasmoid
Browse files Browse the repository at this point in the history
  • Loading branch information
grissiom committed Apr 17, 2009
1 parent f1cda9b commit 66b41da
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 0 deletions.
23 changes: 23 additions & 0 deletions TurnOffScreen/Makefile
@@ -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}
Binary file added TurnOffScreen/blank-screen.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions TurnOffScreen/contents/code/.gitignore
@@ -0,0 +1,2 @@
# let make to generate it
gui.py
Binary file added TurnOffScreen/contents/code/blank-screen.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions TurnOffScreen/contents/code/gui.qrc
@@ -0,0 +1,5 @@
<RCC>
<qresource>
<file>blank-screen.png</file>
</qresource>
</RCC>
45 changes: 45 additions & 0 deletions TurnOffScreen/contents/code/main.py
@@ -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)
17 changes: 17 additions & 0 deletions TurnOffScreen/metadata.desktop
@@ -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.