Skip to content

Instantly share code, notes, and snippets.

@lispandfound
Created August 20, 2017 10:34
Show Gist options
  • Save lispandfound/40af5c09bfd517f2770ea731cb77fa84 to your computer and use it in GitHub Desktop.
Save lispandfound/40af5c09bfd517f2770ea731cb77fa84 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import json
import sys
import subprocess
def stop_running_task():
subprocess.run(['timetrap', 'out'])
def start_task(task):
sheet = task.get('sheet', 'default')
subprocess.run(['timetrap', 'sheet', sheet])
subprocess.run(['timetrap', 'in', task['description']])
def main():
old = json.loads(sys.stdin.readline())
new = json.loads(sys.stdin.readline())
print(json.dumps(new))
if 'start' in new and 'start' not in old:
# Start task
start_task(new)
elif 'start' not in new and 'start' in old:
# Stop task
stop_running_task()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment