Last active
November 11, 2018 22:19
-
-
Save daroczig/802f956a33194fd181e298ea204185b1 to your computer and use it in GitHub Desktop.
Argos script to print currently tracked tasked from Time ++ https://github.com/zagortenay333/timepp__gnome/issues/80
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 python | |
import dbus, dbus.exceptions | |
import sys | |
import re | |
try: | |
bus = dbus.SessionBus() | |
timetracker = bus.get_object('org.gnome.Shell', '/timepp/zagortenay333/TimeTracker') | |
except dbus.exceptions.DBusException as e: | |
print('D-Bus error: {}'.format(str(e))) | |
sys.exit(2) | |
tracked_tasks = timetracker.get_dbus_method('get_tracked_tasks', 'timepp.zagortenay333.TimeTracker')() | |
tracked_tasks = tracked_tasks.split('___timepp___') | |
## get the first tracked task (if we might track multiple tasks) | |
tracked_task = tracked_tasks[0] | |
## remove any priority, optional dates etc from the beginning of the task | |
tracked_task = re.sub(r'^(\([A-Z]\))?[ ]*([0-9]{4}-[0-9]{2}-[0-9]{2})?[ ]*', '', tracked_task) | |
## get the first word (hopefully Jira ticket ID reference) | |
tracked_task = tracked_task.split(' ')[0] | |
## highlight if tracker running | |
print(tracked_task + (' | color="#f47e00"' if tracked_task != 'none' else '')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment