- # hours remaining in the day:
-
- # work+study in the last week, not counting today.
- # no arg to printf for the intentional behavior of no arg
- # shellcheck disable=SC2183
- cache=/tmp/timetrap$(printf '%(%F)T')
- if [[ -e $cache ]]; then
- eval $(<$cache)
- else
- week=$(td -s '8 days ago' -e 'yesterday')
- printf 'week="%s"\n' "$week" >$cache
- week4=$(td -s '29 days ago' -e 'yesterday')
- printf 'week4="%s"\n' "$week4" >>$cache
- fi
- # weekly work+study in the last 4 weeks, not counting today.
- # todo later:
- # 4 weeks
- # ($x4week + $w4week + .05) /4
- #weekly work+study in the last 16 weeks, not counting today.
- #weekly work+study in the last 52 weeks, not counting today.
-
- unixtime=$EPOCHSECONDS
- midnight=$(date +%s -d 'tomorrow 00:00')
- tmp=($(echo "scale=1; today_left=($midnight-$unixtime) / 60 / 60;
-today_left;
-done_today=($today + .05) /1;
-/* hours I could do today by working 80% of the remainder time */
-today_left * .8 + done_today;
-done_today;
-($week + .05) /1;
-($week4 + .05) /4"|bc))
- printf "[ { \"full_text\": \""
- if [[ $ps_char ]]; then
- printf "%s| " "$ps_char"
+
+ # after 24 hours, reset the day start
+ if (( day_start + 24 * 60 * 60 < EPOCHSECONDS )); then
+ day_start=$(date -d $day_start_hour:$day_start_min +%s)