diff options
Diffstat (limited to 'bin/task/context')
| -rwxr-xr-x | bin/task/context | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bin/task/context b/bin/task/context index fd10baf..3e69db4 100755 --- a/bin/task/context +++ b/bin/task/context | |||
| @@ -6,12 +6,13 @@ | |||
| 6 | # context (Check total time of each context) | 6 | # context (Check total time of each context) |
| 7 | # | 7 | # |
| 8 | # TODO support minus time | 8 | # TODO support minus time |
| 9 | # | ||
| 10 | trap 'exit 1' SIGUSR1 | ||
| 11 | trap 'which rsync_retry.sh &>/dev/null && setsid rsync_retry.sh $LOG_FILE &>/dev/null &' EXIT | ||
| 9 | 12 | ||
| 10 | LOG_FILE=~/.context && touch $LOG_FILE | 13 | LOG_FILE=~/.context && touch $LOG_FILE |
| 11 | PLAN_FILE=~/log/plan.context.md | 14 | PLAN_FILE=~/log/plan.context.md |
| 12 | PROC=$$ | 15 | PROC=$$ |
| 13 | trap 'exit 1' SIGUSR1 | ||
| 14 | trap 'rsync_retry $0' EXIT | ||
| 15 | 16 | ||
| 16 | context="$(cat ~/.task/context)" | 17 | context="$(cat ~/.task/context)" |
| 17 | [[ "$*" =~ '-s' ]] && SET=true && shift | 18 | [[ "$*" =~ '-s' ]] && SET=true && shift |
| @@ -75,11 +76,14 @@ _update_spend_time() { | |||
| 75 | while read -r ctx sec; do | 76 | while read -r ctx sec; do |
| 76 | if [ "$ctx" = "$context" ]; then | 77 | if [ "$ctx" = "$context" ]; then |
| 77 | total=$(( "$sec" + "$given_seconds" )) | 78 | total=$(( "$sec" + "$given_seconds" )) |
| 78 | [ "$SET" = true ] && break | 79 | if [ "$SET" = true ]; then |
| 79 | 80 | sed -i -E "/^${context}.*/d" $LOG_FILE | |
| 80 | sed -i -E "s/^${context}.*/${context}\t${total}/" $LOG_FILE | 81 | break |
| 81 | _desktop_notify "$(_format_seconds ${total})" | 82 | else |
| 82 | exit 0 | 83 | sed -i -E "s/^${context}.*/${context}\t${total}/" $LOG_FILE |
| 84 | _desktop_notify "$(_format_seconds ${total})" | ||
| 85 | exit 0 | ||
| 86 | fi | ||
| 83 | fi | 87 | fi |
| 84 | # Update Log file | 88 | # Update Log file |
| 85 | done <"$LOG_FILE" | 89 | done <"$LOG_FILE" |