polybar: todoist
This commit is contained in:
parent
5910be0bf2
commit
f68ff95658
2 changed files with 44 additions and 0 deletions
|
@ -51,6 +51,15 @@ tray-background = #888888
|
|||
cursor-click = pointer
|
||||
cursor-scroll = ns-resize
|
||||
|
||||
[module/todoist]
|
||||
type = custom/script
|
||||
exec = python3 -u /home/mg/dotfiles/polybar/scripte/todoist.py
|
||||
tail = true
|
||||
click-left = xdg-open https://todoist.com
|
||||
format-prefix = "TODO "
|
||||
format-prefix-foreground = ${colors.foreground-alt}
|
||||
|
||||
|
||||
[module/nightscout_script]
|
||||
type = custom/script
|
||||
exec = /home/mg/dotfiles/polybar/scripte/nightscout_cgm.sh
|
||||
|
|
35
polybar/scripte/todoist.py
Normal file
35
polybar/scripte/todoist.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
import subprocess
|
||||
import datetime
|
||||
import todoist
|
||||
import time
|
||||
|
||||
def api_token():
|
||||
return subprocess.run([XXX], capture_output=True, text=True).stdout
|
||||
|
||||
|
||||
def filter_dueToday(item):
|
||||
if item['checked']: return False;
|
||||
if item['due'] == None: return False;
|
||||
|
||||
duedate = datetime.datetime.strptime(item['due']['date'][0:10],'%Y-%m-%d').date()
|
||||
|
||||
return duedate == datetime.date.today()
|
||||
|
||||
|
||||
def countTasks(items):
|
||||
count = {1: 0, 2: 0, 3: 0, 4: 0}
|
||||
for item in items:
|
||||
count[item['priority']] += 1
|
||||
return count
|
||||
|
||||
|
||||
api = todoist.TodoistAPI(api_token())
|
||||
|
||||
while True:
|
||||
try:
|
||||
api.sync()
|
||||
count = countTasks(api.items.all(filt=filter_dueToday))
|
||||
print('%{{B#de4c4a}} {0[4]} %{{B-}}%{{B#f49c18}} {0[3]} %{{B-}}%{{B#4073d6}} {0[2]} %{{B-}}%{{B#444444}} {0[1]} %{{B-}}'.format(count))
|
||||
except:
|
||||
print(' ERROR ')
|
||||
time.sleep(10)
|
Loading…
Reference in a new issue