Advertisement
KrystianD

Control music volume via remote controller

Jan 13th, 2015
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. # Automation script for KDhome (Home automation system) - http://krystiand.net/projekt/12/kdhome
  2.  
  3. import kdhome
  4. import ircodes
  5.  
  6. def run(cmd):
  7.     subprocess.Popen(cmd, shell=True)
  8.  
  9. class Light(kdhome.KDHome):
  10.  
  11.     def __init__(self):
  12.         super().__init__()
  13.  
  14.     def onIRPressedEvent(self, code):
  15.         if code == ircodes.mediatech.MUTE:
  16.             run("~/apps/sound_mute_toggle.sh")
  17.  
  18.     def onIRNewCodeEvent(self, code):
  19.         if code == ircodes.mediatech.UP:
  20.             run("amixer -c 0 set Master 2%+")
  21.         if code == ircodes.mediatech.DOWN:
  22.             run("amixer -c 0 set Master 2%-")
  23.  
  24. home = Light()
  25. home.connect("localhost", 9999)
  26. home.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement