Skip to content

Instantly share code, notes, and snippets.

@Torxed
Created January 5, 2017 00:37
Show Gist options
  • Save Torxed/00c4820a420df1f12bcb191ea8ecaf01 to your computer and use it in GitHub Desktop.
Save Torxed/00c4820a420df1f12bcb191ea8ecaf01 to your computer and use it in GitHub Desktop.
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