2021-06-15 12:50:51 -07:00
|
|
|
import os
|
|
|
|
import requests
|
|
|
|
import threading
|
|
|
|
import json
|
2021-06-17 14:33:40 -07:00
|
|
|
import time
|
2021-06-15 12:50:51 -07:00
|
|
|
|
|
|
|
def get_img():
|
2021-06-17 14:33:40 -07:00
|
|
|
os.system('xwd -root -silent | convert xwd:- img.bmp')
|
2021-06-15 12:50:51 -07:00
|
|
|
|
|
|
|
with open('crops.json') as f:
|
|
|
|
crops = json.load(f)
|
|
|
|
|
|
|
|
threads = []
|
|
|
|
for crop in crops:
|
|
|
|
threads.append(threading.Thread(target=os.system, args=(f'convert img.bmp -crop {crop} pieces/{crop.split("+", 1)[1].replace("+", "x")}.jpg',)))
|
|
|
|
threads[-1].start()
|
|
|
|
for thread in threads:
|
|
|
|
thread.join()
|
|
|
|
|
|
|
|
os.system("md5sum -c oldlist 2>/dev/null | grep FAILED > newlist")
|
|
|
|
changed = []
|
|
|
|
with open('newlist') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
for line in lines:
|
|
|
|
changed.append(line.split(": ")[0].split('.')[0].split('/')[1])
|
|
|
|
os.system("md5sum pieces/* > oldlist")
|
|
|
|
return changed
|
|
|
|
|
|
|
|
def get_full_img():
|
2021-06-17 14:33:40 -07:00
|
|
|
os.system('xwd -root -silent | convert xwd:- full.jpg')
|
2021-06-15 12:50:51 -07:00
|
|
|
return 'full.jpg'
|
|
|
|
|
2021-06-17 14:33:40 -07:00
|
|
|
def touch(x, y, w, is_long):
|
2021-06-15 12:50:51 -07:00
|
|
|
x = round(800 * x / w)
|
|
|
|
y = round(800 * y / w)
|
2021-06-17 14:33:40 -07:00
|
|
|
if is_long:
|
|
|
|
os.system(f'xdotool mousemove {x} {y} mousedown 1')
|
|
|
|
time.sleep(2)
|
|
|
|
os.system(f'xdotool mouseup 1')
|
|
|
|
else:
|
|
|
|
os.system(f'xdotool mousemove {x} {y} click 1')
|