Skip to content

Instantly share code, notes, and snippets.

Last active Jan 6, 2021
What would you like to do?
A python script to notify you of your current TimeWarrior task
#!/usr/bin/env python
# Notifies the user of the curently active TimeWarrior task every m minutes (default 10min).
# Requirements
# - python 2.7
# - pynotify
# Usage:
# python [optional seconds]
import sys
import pynotify
from subprocess import check_output, CalledProcessError
from time import sleep
def readtask():
lines = check_output(["timew"]).split('\n')
except CalledProcessError:
return None
lines = [_.strip() for _ in lines]
name = lines[0][len('Tracking'):].strip()
time = lines[3].split()[1]
return name, time
# check if anything is active
def start(seconds=10*60):
while True:
task = readtask()
msg = '<h3><font color="red"> No task in progress</font></h3>'
if task:
msg = """<h3><b>
Working on
<font color="red">{}</font> ({})</b></h3>
n = pynotify.Notification("<h2>TimeWarrior</h2>", msg)
if __name__ == '__main__':
# read time in seconds from arguments, or use 10 minutes as default
time = float(sys.argv[1]) if len(sys.argv) >= 2 else 10*60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment