Skip to content

Commit

Permalink
Add internal DPMS and CEC methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers committed Apr 12, 2018
1 parent f79f166 commit beefc27
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ It supports the following methods:

- Raspberry Pi (vcgencmd)
- X11 DPMS (xset)
- DPMS (internal)
- CEC Standby (internal)

Optionally this screensaver can also log off your user.

2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="screensaver.nosignal" name="No Signal" version="0.7.4" provider-name="Dag Wieers">
<addon id="screensaver.nosignal" name="No Signal" version="0.8.0" provider-name="Dag Wieers">
<extension point="xbmc.addon.metadata">
<platform>linux</platform>
<summary lang="en">Screensaver that turns your screen off to save power</summary>
Expand Down
23 changes: 22 additions & 1 deletion nosignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ def onInit(self):
subprocess.call(['vcgencmd', 'display_power', '0'])
elif method == '2':
subprocess.call(['xset', 'dpms', 'force', 'off'])
elif method == '3':
try:
xbmc.executebuiltin('ToggleDPMS')
except Exception as e:
xbmc.log(msg="%s Failed to toggle DPMS: %s" % (addon_name, e), level=xbmc.LOGERROR)
elif method == '4':
try:
xbmc.executebuiltin('CECStandby')
except Exception as e:
xbmc.log(msg="%s Failed to turn device off via CEC: %s" % (addon_name, e), level=xbmc.LOGERROR)


def onAction(self):
self.exit()
Expand All @@ -42,8 +53,18 @@ def exit(self):
subprocess.call(['vcgencmd', 'display_power', '1'])
elif method == '2':
subprocess.call(['xset', 'dpms', 'force', 'on'])
elif method == '3':
try:
xbmc.executebuiltin('ToggleDPMS')
except Exception as e:
xbmc.log(msg="%s Failed to toggle DPMS: %s" % (addon_name, e), level=xbmc.LOGERROR)
elif method == '4':
try:
xbmc.executebuiltin('CECActivateSource')
except Exception as e:
xbmc.log(msg="%s Failed to turn device off via CEC: %s" % (addon_name, e), level=xbmc.LOGERROR)

self.close()
self.close()

if __name__ == '__main__':
addon = xbmcaddon.Addon()
Expand Down
2 changes: 2 additions & 0 deletions resources/language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<string id="30011">Do nothing</string>
<string id="30012">Raspberry Pi (vcgencmd)</string>
<string id="30013">X11 DPMS (xset)</string>
<string id="30014">DPMS (internal)</string>
<string id="30015">CEC Standby (internal)</string>
<string id="30100">Log off user when (activating screensaver)</string>

</strings>
2 changes: 1 addition & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<settings>
<setting label="30010" type="enum" id="method" lvalues="30011|30012|30013" default="1"/>
<setting label="30010" type="enum" id="method" lvalues="30011|30012|30013|30014|30015" default="1"/>
<setting label="30100" type="bool" id="logoff" default="true"/>
</settings>

0 comments on commit beefc27

Please sign in to comment.