Skip to content

Instantly share code, notes, and snippets.

@brainrake
Last active August 29, 2015 14:10
Show Gist options
  • Save brainrake/c65e4c2c523f4f1be5bc to your computer and use it in GitHub Desktop.
Save brainrake/c65e4c2c523f4f1be5bc to your computer and use it in GitHub Desktop.
tv install
"python2 switch.py 1"
1
"python2 switch.py 2"
2
"python2 switch.py 3"
3
"amixer set Master 5+"
Up
"amixer set Master 5-"
Down
"killall xbindkeys; killall mpv"
alt+k
import sys, subprocess, csv, datetime
fn = sys.argv[1]
w = csv.writer(open(fn+'.csv', 'wb'))
for f in open(fn+'.txt').readlines():
v = f.strip()
if v:
cmd = 'ffprobe -i "%s" -show_entries format=duration -v quiet -of csv="p=0"' % v
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
r = p.stdout.read().strip()
s = int(r.partition('.')[0])
print s,v
w.writerow([s, v])
import os, sys, datetime, csv
def dt2t(dt):
return datetime.time(hour=(dt.seconds/60/60)%30, minute=(dt.seconds/60)%30, second=dt.seconds%60)
def t2dt(t):
return datetime.timedelta(hours=t.hour, minutes=t.minute, seconds=t.second)
if len(sys.argv) <= 1:
os.system('killall mpv')
os.system('killall xbindkeys')
os.system('xbindkeys')
os.system('xsetroot -solid black')
sys.exit(1)
chan = 0
now = datetime.datetime.now().time().replace(microsecond=0)
chan = sys.argv[1]
if len(sys.argv) >= 3:
now = datetime.datetime.strptime(sys.argv[2], '%H:%M:%S').time()
print 'chan', chan
print 'now', now
os.system('killall mpv')
if now < datetime.time(hour=11, minute=0, second=0):
now = now.replace(hour=now.hour + 13)
else:
now = now.replace(hour=now.hour - 11)
pl = []
total = datetime.timedelta(0)
start = datetime.timedelta(0)
r = csv.reader(open(chan+'.csv', 'r'))
for row in r:
this = datetime.timedelta(seconds=int(row[0]))
print row, total, this
if dt2t(total) > now:
pl.append(row[1])
else:
if dt2t(total+this) > now:
start = t2dt(now) - total
pl.append(row[1])
print 'AAAAAAAAAAAA'
total += this
print pl
print total
print start
plt = ' '.join(['"%s"'% v for v in pl])
print plt
cl = 'mpv --no-osc --osd-level=0 --start=%s --wid=0 %s' % (str(start), plt)
print cl
os.system(cl)
enable extra repos
sudo apt-get install mpv xbindkeys i3
switch.py
.xbindkeysrc
/etc/lightdm/lightdm.conf >> autologin-session=i3
.i3/config >> bar >> mode hide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment