diff options
Diffstat (limited to 'hm/soispha/conf/taskwarrior/hooks')
5 files changed, 68 insertions, 53 deletions
diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh index 9ac1ab91..6f09a7e6 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_enforce-policies.sh @@ -6,37 +6,36 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } enforce_project() { - project="$(jq '.project' "$(ptmp "$1")")"; + project="$(jq '.project' "$(ptmp "$1")")" [ "$project" = "null" ] && die "No project supplied!" if grep -q "^$(echo "$project" | sed 's|"\(.*\)"|\1|')\$" "$(ptmp "%PROJECTS_NEWLINE")"; then - dbg "project('$project') is a valid part of %PROJECTS_COMMA"; + dbg "project('$project') is a valid part of %PROJECTS_COMMA" else - die "The project '$(echo "$project" | sed 's|"||g')' is not registered with the nix config, registered projects: %PROJECTS_COMMA"; + die "The project '$(echo "$project" | sed 's|"||g')' is not registered with the nix config, registered projects: %PROJECTS_COMMA" fi } - -read -r new_task; +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -enforce_project "$new_task"; +enable_hook_dbg +enforce_project "$new_task" -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh index 8a776d3a..085115e7 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-add_sync-git-repo.sh @@ -6,38 +6,37 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } update_git_repo() { - task_data="$(task _get rc.data.location)"; + task_data="$(task _get rc.data.location)" [ "$task_data" ] || die "Taskwarrior should have a location set" cd "$task_data" || die "(BUG?): Your data.location path is not accessable" [ -d ./.git/ ] || git init - git add .; - git commit --message="chore: Update" --no-gpg-sign; + git add . + git commit --message="chore: Update" --no-gpg-sign } - -read -r new_task; +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -update_git_repo; +enable_hook_dbg +update_git_repo -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh index b043f141..996e105a 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_sync-git-repo.sh @@ -6,39 +6,38 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # override shell lib output to stdout eprint() { # shellcheck disable=SC2317 - print "$@"; -}; + print "$@" +} eprintln() { # shellcheck disable=SC2317 - println "$@"; -}; + println "$@" +} enable_hook_dbg() { - debug_hooks="$(task _get rc.debug.hooks)"; + debug_hooks="$(task _get rc.debug.hooks)" [ "$debug_hooks" ] && [ "$debug_hooks" -ge 1 ] && dbg_enable } update_git_repo() { - task_data="$(task _get rc.data.location)"; + task_data="$(task _get rc.data.location)" [ "$task_data" ] || die "Taskwarrior should have a location set" cd "$task_data" || die "(BUG?): Your data.location path is not accessable" [ -d ./.git/ ] || git init - git add .; - git commit --message="chore: Update" --no-gpg-sign; + git add . + git commit --message="chore: Update" --no-gpg-sign } - -read -r _old_task; -read -r new_task; +read -r _old_task +read -r new_task # We don't change the task, thus immediately return the json -echo "$new_task"; +echo "$new_task" -enable_hook_dbg; -update_git_repo; +enable_hook_dbg +update_git_repo -exit 0; +exit 0 # vim: ft=sh diff --git a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py index 03b4ce42..c8efb596 100755 --- a/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py +++ b/hm/soispha/conf/taskwarrior/hooks/scripts/on-modify_track-timewarrior.py @@ -70,12 +70,17 @@ combined = " ".join(["'%s'" % tag for tag in tags]).encode("utf-8").strip() # Task has been started. if "start" in new and not "start" in old: # 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) system("timew start " + combined.decode() + " :yes") 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=(",", ":")) |