aboutsummaryrefslogtreecommitdiff
path: root/gromo
diff options
context:
space:
mode:
Diffstat (limited to 'gromo')
-rwxr-xr-xgromo41
1 files changed, 29 insertions, 12 deletions
diff --git a/gromo b/gromo
index 63cb7c3..cadd495 100755
--- a/gromo
+++ b/gromo
@@ -35,8 +35,8 @@ cmd_help() {
echo -e "Usage:
$cmd -h \tShow this help
$cmd -s \tShow status
+ $cmd -x \tShow status formatted for xmobar
$cmd -l \tList past gromos
- $cmd -x \tReturn state formatted for display in xmobar
$cmd [options] <task>\tStart task
Options:
@@ -57,12 +57,12 @@ cmd_list() {
cmd_status() {
format=$1
- state=idle
- [ -f "$STATE_FILE" ] && state=$(cat "$STATE_FILE")
+ status=idle
+ [ -f "$STATE_FILE" ] && status=$(cat "$STATE_FILE")
if [ "$format" = "xmobar" ]; then
color=red
- [ "$state" = "idle" ] && color=green
+ [ "$status" = "idle" ] && color=green
if [ -d "$TODAY_DIR" ]; then
today=""
@@ -73,14 +73,31 @@ cmd_status() {
[ -n "$today" ] && today=" (${today%, })"
fi
- echo "<fc=$color>$state</fc>$today"
+ echo "<fc=$color>$status</fc>$today"
else
- echo -e "state: $state\n"
+ echo -e "status: $status\n"
if [ -d "$TODAY_DIR" ]; then
# needs nullglob
for task_file in "$TODAY_DIR"/*; do
- sort < "$task_file"
+ out=$(
+ awk -F $FS -f - "$task_file" <<EOF
+{ tasks[\$1][\$2] = \$3 }
+END {
+ for (task in tasks) {
+ for (dur in tasks[task]) {
+ gromos += tasks[task][dur];
+ time += dur * tasks[task][dur]
+ };
+ print task ":" time ":" gromos
+ }
+}
+EOF
+ )
+
+ while IFS=$FS read -r task dur gromos; do
+ echo -e "$task\n\t$gromos gromos, $(pp_seconds $dur)"
+ done <<<"$out"
done
fi
fi
@@ -119,7 +136,7 @@ pp_seconds() {
fi
}
-optspec="1hslx"
+optspec="1hsxl"
while getopts "$optspec" optchar; do
case "$optchar" in
1)
@@ -134,14 +151,14 @@ while getopts "$optspec" optchar; do
cmd_status
exit 0
;;
- l)
- cmd_list
- exit 0
- ;;
x)
cmd_status xmobar
exit 0
;;
+ l)
+ cmd_list
+ exit 0
+ ;;
*)
cmd_help
exit -1