Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion screensaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
''' This Kodi addon turns off display devices when Kodi goes into screensaver-mode '''

from __future__ import absolute_import, division, unicode_literals
import os
import sys
import atexit
from xbmc import Monitor
from xbmcgui import WindowXMLDialog

# On some systems, commands might be in directories not on PATH env var, e.g. `vcgencmd` is under
# /opt/vc/bin/ on OSMC. Add these paths to ensure the commands work on all systems.
PATH = ':'.join((os.environ.get('PATH', ''),'/opt/vc/bin'))

# NOTE: The below order relates to resources/settings.xml
DISPLAY_METHODS = [
dict(name='do-nothing', title='Do nothing',
Expand Down Expand Up @@ -212,7 +217,7 @@ def run_command(*command, **kwargs):
import subprocess
# TODO: Add options for running using su or sudo
try:
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, **kwargs)
cmd = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, env={"PATH": PATH}, **kwargs)
(out, err) = cmd.communicate()
if cmd.returncode == 0:
log(2, "Running command '{command}' returned rc={rc}", command=' '.join(command), rc=cmd.returncode)
Expand Down