A bin folder, holding helpfull scripts and commands
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python2
  2. import subprocess
  3. import time
  4. from kodijson import Kodi # sudo pip install kodi-json
  5. def monitor_state():
  6. mon_state = subprocess.check_output(['/usr/bin/tvservice', '-s'])
  7. return mon_state.split(' ')[1] in ['0xa', '0x12000a', '0x40002']
  8. def kodi_state():
  9. kodi = Kodi("http://tv:8080/jsonrpc")
  10. ap = kodi.Player.GetActivePlayers()
  11. print(ap)
  12. return len(ap['result']) > 0
  13. prev_state = None
  14. while True:
  15. # second count
  16. curr_state = kodi_state()
  17. # check if there is a change in the screen state
  18. if curr_state != prev_state:
  19. if curr_state is True:
  20. subprocess.check_output(['sispmctl', '-o', '1'])
  21. else:
  22. subprocess.check_output(['sispmctl', '-f', '1'])
  23. prev_state = curr_state
  24. time.sleep(1.)