From d5e4f287d6acfe6f026f222e89ef6e1c28bb9db0 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Thu, 20 Apr 2023 10:13:24 +0800 Subject: Improve context --- bin/task/context | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bin/task/context') 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() { } _desktop_notify() { - which notify-send &>/dev/null && notify-send "$context +$1" + which notify-send &>/dev/null || return 1 + if [[ "$1" =~ ^[+-] ]]; then + local time="$1" + else + local time=+"$1" + fi + notify-send "$context $time" } # Update spend time on current context @@ -80,7 +86,7 @@ _update_spend_time() { fi given_seconds="$(_get_seconds "$time")" - _desktop_notify "$(_format_seconds "${given_seconds}")" + _desktop_notify "$time" echo -e "$(date +'%Y%m%d %H:%M:%S')\t$context\t${given_seconds}" >>$LOG_FILE } -- cgit v1.2.3-70-g09d2