__email__ = "alex@lisas.de"
__license__ = "GPLv2"
-import pylirc, time, socket, os, signal, subprocess
+import pylirc, time, socket, os, signal, subprocess, sys
vomp_host = '127.0.0.1'
vomp_port = 2000
repeaters = [ VOMP_CHANNELUP, VOMP_CHANNELDOWN ]
debug = False
+def led_off():
+ os.system('echo 0 | sudo tee /sys/class/leds/led0/brightness')
+
+def led_on():
+ os.system('echo 1 | sudo tee /sys/class/leds/led0/brightness')
+
+def set_mode(newmode):
+ global mode
+ if mode != newmode:
+ if newmode == VOMPILIRC_MODE_OFF:
+ # we switch from either xbmc or vomp to off
+ led_off()
+ elif mode == VOMPILIRC_MODE_OFF:
+ # we switch from off to either xbmc or vomp
+ led_on()
+
+ mode = newmode
+
def start_vomp():
global mode
global child_pipe
if debug:
print 'Starting vompclient'
- mode = VOMPILIRC_MODE_VOMP
+ set_mode(VOMPILIRC_MODE_VOMP)
child_pipe = subprocess.Popen(['vompclient','-n'])
def start_xbmc():
if debug:
print 'Starting XBMC'
- mode = VOMPILIRC_MODE_XBMC
+ set_mode(VOMPILIRC_MODE_XBMC)
child_pipe = subprocess.Popen(['/usr/lib/xbmc/xbmc.bin', '--standalone'])
tv_power(off=True)
child_pipe = None
- mode = VOMPILIRC_MODE_OFF
+ set_mode(VOMPILIRC_MODE_OFF)
def signal_handler(signum, frame):
if debug: print 'Exiting...'