Created
September 14, 2018 03:09
-
-
Save cm3/2709308cac8326a67f6194d4abfcbb2d 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/env python3 | |
import os | |
import time | |
import sys | |
from datetime import datetime | |
from win10toast import ToastNotifier | |
import pyscreenshot | |
from PIL import Image | |
from tqdm import tqdm | |
tqdm.monitor_interval = 0 | |
imgdir = 'images' | |
def capture_and_save(shrink_factor=8): | |
im = pyscreenshot.grab() | |
width, height = im.size | |
im = im.resize((width // shrink_factor, height // shrink_factor), Image.LANCZOS) | |
timestamp = datetime.now().strftime('%Y%m%d-%H%M%S') | |
filename = imgdir+'/%s.png' % timestamp | |
im.save(filename) | |
def main(num_pomodori): | |
os.makedirs(imgdir, exist_ok=True) | |
toaster = ToastNotifier() | |
for i in range(1, num_pomodori + 1): | |
print('Pomodoro #%i (started on %s)' % (i, datetime.now().strftime('%Y%m%d-%H%M%S'))) | |
toaster.show_toast('pomo', 'work started') | |
# pomorodo | |
for _ in tqdm(range(25), ncols=80): | |
time.sleep(60) | |
capture_and_save() | |
# break | |
toaster.show_toast('pomo', 'break started') | |
for _ in tqdm(range(5), ncols=80): | |
time.sleep(60) | |
capture_and_save() | |
if __name__ == '__main__': | |
if len(sys.argv) >= 2: | |
num_pomodori = int(sys.argv[1]) | |
else: | |
num_pomodori = 4 | |
main(num_pomodori) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment