Skip to content

Instantly share code, notes, and snippets.

@xgdgsc
Created September 18, 2017 13:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xgdgsc/3d0cda9cc4c011fbbfecbc9c22f68c71 to your computer and use it in GitHub Desktop.
Save xgdgsc/3d0cda9cc4c011fbbfecbc9c22f68c71 to your computer and use it in GitHub Desktop.
pomotodo task switch reminder
import requests
import json
from datetime import datetime, timedelta
import os
if os.name == 'nt':
from win10toast import ToastNotifier
toaster = ToastNotifier()
//from config import *
POMO_URL='https://api.pomotodo.com/1/pomos'
API_TOKEN='YOUR TOKEN'
headers = {'Authorization': 'token '+API_TOKEN}
parameters = {'started_later_than': (datetime.today() - timedelta(days=1)).strftime('%Y-%m-%d')}
result = requests.get(POMO_URL, headers=headers, params=parameters)
result_j = result.json()
if len(result_j) > 8:
last_res = result_j[-8:]
else:
last_res = result_j
task_dict = {}
for pomo in last_res:
description = pomo['description']
for task in description.split('+'):
task = task.strip()
if task in task_dict:
task_dict[task] += 1
else:
task_dict[task] = 1
for key in task_dict:
if task_dict[key] >=8:
if os.name == 'nt':
toaster.show_toast("Pomo Reminder",
key + ' is enough, Time to switch task!')
else:
os.system('notify-send "{}" "{}"'.format('Pomo Reminder', key + ' is enough, Time to switch task!'))
break
elif task_dict[key] <8:
# os.system('notify-send "{}" "{}"'.format('pomo-reminder', 'not time to switch task!'))
pass
print(task_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment