Last active
August 29, 2015 13:55
-
-
Save philihp/8733622 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
#!/usr/bin/python | |
from subprocess import call | |
import sys | |
import urllib2 | |
import hashlib | |
import struct | |
import shutil | |
OLDFILE = '/tmp/newcolor.txt' | |
NEWFILE = '/tmp/oldcolor.txt' | |
URL = 'https://philihp.com/color.txt' | |
call(['touch',OLDFILE]) | |
call(['touch',NEWFILE]) | |
webcolor = urllib2.urlopen(URL) | |
newfile = open(NEWFILE,'wb') | |
newfile.write(webcolor.read()) | |
newfile.close() | |
newmd5 = hashlib.md5(open(NEWFILE).read()).hexdigest() | |
oldmd5 = hashlib.md5(open(OLDFILE).read()).hexdigest() | |
if newmd5 == 'd41d8cd98f00b204e9800998ecf8427e': | |
sys.exit(0) | |
if(newmd5 != oldmd5): | |
shutil.copy2(NEWFILE, OLDFILE) | |
for line in open(NEWFILE).readlines(): | |
if line.startswith('#'): | |
color = line | |
print "Blinking ", color | |
cr = color[1:3] | |
cg = color[3:5] | |
cb = color[5:7] | |
call( ['/home/philihp/bin/blink1-tool','--rgb','0x'+cr+',0x'+cg+',0x'+cb,'--blink','3']) | |
call( ['/home/philihp/bin/blink1-tool','--rgb','0x'+cr+',0x'+cg+',0x'+cb]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment