Created
August 20, 2017 10:34
-
-
Save lispandfound/40af5c09bfd517f2770ea731cb77fa84 to your computer and use it in GitHub Desktop.
This file contains 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 characters
#!/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