From 2c14bcea4c65c762c4d969bc22485facf1419045 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Thu, 20 Apr 2023 10:49:03 +0800 Subject: Update --- bin/task/context | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin/task/context') 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() { # Get formated string from given seconds _format_seconds() { hour=$(( $1 / 3600 )) + [ "$hour" = 0 ] && unset hour min=$(( ($1 % 3600) / 60 )) + [ "$min" = 0 ] && unset min sec=$(( $1 % 60 )) + [ "$sec" = 0 ] && unset sec - echo ${hour}h${min}m${sec}s + echo ${hour:+${hour}h}${min:+${min}m}${sec:+${sec}s} } _save_spend_time_to_dic() { @@ -70,7 +73,7 @@ _save_spend_time_to_dic() { _desktop_notify() { which notify-send &>/dev/null || return 1 - if [[ "$1" =~ ^[+-] ]]; then + if [[ "$1" =~ ^- ]]; then local time="$1" else local time=+"$1" @@ -86,7 +89,7 @@ _update_spend_time() { fi given_seconds="$(_get_seconds "$time")" - _desktop_notify "$time" + _desktop_notify "$(_format_seconds "$given_seconds")" echo -e "$(date +'%Y%m%d %H:%M:%S')\t$context\t${given_seconds}" >>$LOG_FILE } -- cgit v1.2.3-70-g09d2