Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<RCC> | |||
<qresource> | |||
<file>blank-screen.png</file> | |||
</qresource> | |||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |