aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbin/task/context9
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/task/context b/bin/task/context
index 358c548..fcba0fb 100755
--- a/bin/task/context
+++ b/bin/task/context
@@ -56,10 +56,13 @@ _get_seconds() {
56# Get formated string from given seconds 56# Get formated string from given seconds
57_format_seconds() { 57_format_seconds() {
58 hour=$(( $1 / 3600 )) 58 hour=$(( $1 / 3600 ))
59 [ "$hour" = 0 ] && unset hour
59 min=$(( ($1 % 3600) / 60 )) 60 min=$(( ($1 % 3600) / 60 ))
61 [ "$min" = 0 ] && unset min
60 sec=$(( $1 % 60 )) 62 sec=$(( $1 % 60 ))
63 [ "$sec" = 0 ] && unset sec
61 64
62 echo ${hour}h${min}m${sec}s 65 echo ${hour:+${hour}h}${min:+${min}m}${sec:+${sec}s}
63} 66}
64 67
65_save_spend_time_to_dic() { 68_save_spend_time_to_dic() {
@@ -70,7 +73,7 @@ _save_spend_time_to_dic() {
70 73
71_desktop_notify() { 74_desktop_notify() {
72 which notify-send &>/dev/null || return 1 75 which notify-send &>/dev/null || return 1
73 if [[ "$1" =~ ^[+-] ]]; then 76 if [[ "$1" =~ ^- ]]; then
74 local time="$1" 77 local time="$1"
75 else 78 else
76 local time=+"$1" 79 local time=+"$1"
@@ -86,7 +89,7 @@ _update_spend_time() {
86 fi 89 fi
87 90
88 given_seconds="$(_get_seconds "$time")" 91 given_seconds="$(_get_seconds "$time")"
89 _desktop_notify "$time" 92 _desktop_notify "$(_format_seconds "$given_seconds")"
90 93
91 echo -e "$(date +'%Y%m%d %H:%M:%S')\t$context\t${given_seconds}" >>$LOG_FILE 94 echo -e "$(date +'%Y%m%d %H:%M:%S')\t$context\t${given_seconds}" >>$LOG_FILE
92} 95}