diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2023-04-20 10:13:24 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2023-04-20 10:13:24 +0800 |
commit | d5e4f287d6acfe6f026f222e89ef6e1c28bb9db0 (patch) | |
tree | a23ffb881b461adb0b5e6c852594c6ce4de4e717 /bin/task/context | |
parent | a8a7eee0c27c6fc79652bf7abe09a712858c005d (diff) |
Improve context
Diffstat (limited to 'bin/task/context')
-rwxr-xr-x | bin/task/context | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/task/context b/bin/task/context index 1f1dbda..358c548 100755 --- a/bin/task/context +++ b/bin/task/context | |||
@@ -69,7 +69,13 @@ _save_spend_time_to_dic() { | |||
69 | } | 69 | } |
70 | 70 | ||
71 | _desktop_notify() { | 71 | _desktop_notify() { |
72 | which notify-send &>/dev/null && notify-send "$context +$1" | 72 | which notify-send &>/dev/null || return 1 |
73 | if [[ "$1" =~ ^[+-] ]]; then | ||
74 | local time="$1" | ||
75 | else | ||
76 | local time=+"$1" | ||
77 | fi | ||
78 | notify-send "$context $time" | ||
73 | } | 79 | } |
74 | 80 | ||
75 | # Update spend time on current context | 81 | # Update spend time on current context |
@@ -80,7 +86,7 @@ _update_spend_time() { | |||
80 | fi | 86 | fi |
81 | 87 | ||
82 | given_seconds="$(_get_seconds "$time")" | 88 | given_seconds="$(_get_seconds "$time")" |
83 | _desktop_notify "$(_format_seconds "${given_seconds}")" | 89 | _desktop_notify "$time" |
84 | 90 | ||
85 | echo -e "$(date +'%Y%m%d %H:%M:%S')\t$context\t${given_seconds}" >>$LOG_FILE | 91 | echo -e "$(date +'%Y%m%d %H:%M:%S')\t$context\t${given_seconds}" >>$LOG_FILE |
86 | } | 92 | } |