about summary refs log tree commit diff stats
path: root/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-02-20 17:21:42 +0100
committerSoispha <soispha@vhack.eu>2024-02-20 17:21:42 +0100
commitf2bdeaed0bcf97a880fe36cfc8a050d1643120b8 (patch)
treeba4fe9c3ddf076529701c0e776ffef2104ac23d5 /hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py
parentrefactor(treewide): Add a `.sh` extension to shell scripts (diff)
downloadnixos-config-f2bdeaed0bcf97a880fe36cfc8a050d1643120b8.zip
refactor(treewide): Reformat all files with treefmt
This includes getting all shellscripts to pass shellcheck. To accomplish
this, some old scripts were removed
Diffstat (limited to 'hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py')
-rwxr-xr-xhm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py
index 88234cbf..d5b380d0 100755
--- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py
+++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-total-active-time.py
@@ -102,12 +102,17 @@ def main():
     # An active task has just been started.
     if "start" in modified and "start" not in original:
         # Prevent this task from starting if "task +ACTIVE count" is greater than "MAX_ACTIVE".
-        p = subprocess.Popen(["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"], stdout=subprocess.PIPE)
+        p = subprocess.Popen(
+            ["task", "+ACTIVE", "status:pending", "count", "rc.verbose:off"],
+            stdout=subprocess.PIPE,
+        )
         out, err = p.communicate()
         count = int(out.rstrip())
         if count >= MAX_ACTIVE:
-            print("Only %d task(s) can be active at a time. "
-                  "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE)
+            print(
+                "Only %d task(s) can be active at a time. "
+                "See 'max_active_tasks' in .taskrc." % MAX_ACTIVE
+            )
             sys.exit(1)
 
     # An active task has just been stopped.
@@ -119,10 +124,18 @@ def main():
         if UDA_KEY not in modified:
             modified[UDA_KEY] = 0
 
-        this_duration = (end - start)
-        total_duration = (this_duration + duration_str_to_time_delta(str(modified[UDA_KEY])))
-        print("Total Time Tracked: %s (%s in this instance)" % (total_duration, this_duration))
-        modified[UDA_KEY] = str(int(total_duration.days * (60 * 60 * 24) + total_duration.seconds)) + "seconds"
+        this_duration = end - start
+        total_duration = this_duration + duration_str_to_time_delta(
+            str(modified[UDA_KEY])
+        )
+        print(
+            "Total Time Tracked: %s (%s in this instance)"
+            % (total_duration, this_duration)
+        )
+        modified[UDA_KEY] = (
+            str(int(total_duration.days * (60 * 60 * 24) + total_duration.seconds))
+            + "seconds"
+        )
 
     return json.dumps(modified, separators=(",", ":"))