Created
January 5, 2017 00:37
-
-
Save Torxed/00c4820a420df1f12bcb191ea8ecaf01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import signal | |
import os | |
import sys | |
import time | |
import termios | |
old_settings = termios.tcgetattr(sys.stdin) | |
import readchar | |
while 1: | |
key = readchar.readkey() | |
if key == 'q': | |
break | |
elif key == 'm': | |
pro = subprocess.Popen(['omxplayer', '-o', 'local','/home/pi/Music/Disc 2 - Rap Jazzy/06. Q-Tip ft. Heavy D - Listen.flac'], stdout=subprocess.PIPE, preexec_fn=os.setsid) | |
time.sleep(5) | |
os.killpg(os.getpgid(pro.pid), signal.SIGTERM) | |
elif key == 'i': | |
pro = subprocess.Popen(['omxplayer', '-o', 'local', '/home/pi/Music/Disc 2 - Rap Jazzy/02. Malik Yusef - Get Ready (Rmx).flac'], stdout=subprocess.PIPE, preexec_fn=os.setsid) | |
time.sleep(5) | |
os.killpg(os.getpgid(pro.pid), signal.SIGTERM) | |
else: | |
print key | |
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment