From: Scott Worley Date: Sat, 22 Aug 2026 16:01:48 +0000 (-0700) Subject: daily-gaps.sh script X-Git-Url: http://git.scottworley.com/keystroke-timestamps/commitdiff_plain/3a0e7102aa2af9635c86950babc72438593b65fc?ds=sidebyside;hp=2ecebf75f7fd4624e55958b9892d370b36fab220 daily-gaps.sh script --- diff --git a/Changelog b/Changelog index c6c8f65..ca9fbbd 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ ## [Unreleased] - More portable shebangs +- Demo daily-gaps.sh script ## [1.1.0] - 2026-08-21 diff --git a/daily-gaps.sh b/daily-gaps.sh new file mode 100755 index 0000000..090fe6f --- /dev/null +++ b/daily-gaps.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +# Report gaps that contain the target time + +target=${1:-3:30} +threshold=${2:-3600} +LOGFILE="${3:-$HOME/keystroke-timestamps.log}" + +awk -vtarget="$(date -d "$target" '+%H %M %S')" -vthreshold="$threshold" -vtime_fmt="%F %T" ' + function first_target_after(t) { + # TODO: Be smarter for targets near DST changes. :( + target_on_t_day = mktime(strftime("%Y %m %d ", t) target) + target_on_prev_day = mktime(strftime("%Y %m %d ", target_on_t_day - 86400) target) + target_on_next_day = mktime(strftime("%Y %m %d ", target_on_t_day + 86400) target) + if (target_on_prev_day > t) { return target_on_prev_day } + if (target_on_t_day > t) { return target_on_t_day } + return target_on_next_day + } + $1 <= 67767976233561595 { + if (prev && $1 - prev > threshold && $1 > first_target_after(prev)) { + print(strftime(time_fmt, prev), "to", strftime(time_fmt, $1), "was", $1 - prev) + } + prev = $1 + }' "$LOGFILE" diff --git a/gaps.sh b/gaps.sh index 7f8de73..e2144e1 100755 --- a/gaps.sh +++ b/gaps.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + threshold=${1:-3600} LOGFILE="${2:-$HOME/keystroke-timestamps.log}"