A bin folder, holding helpfull scripts and commands
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

amplifier 946B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python2
  2. import subprocess
  3. import time
  4. def monitor_state():
  5. mon_state = subprocess.check_output(['/usr/bin/tvservice', '-s'])
  6. return mon_state.split(' ')[1] in ['0xa', '0x12000a', '0x40002']
  7. def kodi_state():
  8. response = urllib2.urlopen('http://music:8080/jsonrpc?request={%22jsonrpc%22:%20%222.0%22,%20%22method%22:%20%22Player.GetActivePlayers%22,%20%22id%22:%201}')
  9. json_txt = response.read()
  10. response.close() # best practice to close the file
  11. response = json.loads(json_txt)
  12. return len(response['result']) > 0
  13. prev_state = None
  14. while True:
  15. # second count
  16. curr_state = monitor_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.)