Created
August 6, 2020 05:51
-
-
Save uid0/8f32c104a110eeab26eea62207c08713 to your computer and use it in GitHub Desktop.
Revisions
-
uid0 created this gist
Aug 6, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ import sys import json import os # Hook should extract all of the following for use as Timewarrior tags: # UUID # Project # Tags # Description # UDAs # Make no changes to the task, simply observe. old = json.loads(sys.stdin.readline()) new = json.loads(sys.stdin.readline()) print(json.dumps(new)) # Extract attributes for use as tags. tags = [new['description']] if 'project' in new: tags.append(new['project']) if 'tags' in new: tags.extend(new['tags']) combined = ' '.join(['"%s"' % tag for tag in tags]).encode('utf-8').strip() # Started task. if 'start' in new and not 'start' in old: os.system('timew start ' + combined + ' :yes') os.system('stup add -c ' + new['project'] + ' -n "' + new['description'] + '"') # Stopped task. elif not 'start' in new and 'start' in old: os.system('timew stop ' + combined + ' :yes')