t s w
}
+
+# help me focus. opens 2 windows.
focus() {
/p/c/proc/focus/linux-amd64/focus &
watcharb5
}
+# Display a list of the active window title
+# i've been on with 10 second samples going back
+# 5 minutes. If I've been on one window for 10 seconds
+# or longer, then display the second count.
+#
+# Press any key to exit.
watcharb5() {
local char ret
- killall arbtt-capture ||:
+ killall arbtt-capture &>/dev/null ||:
rm -f ~/.arbtt/capture.log
arbtt-capture --sample-rate=10 &
- clear
while true; do
arb5
ret=0
killall arbtt-capture ||:
return 0
fi
- clear
done
}
arb5() {
- local i l sec
- i=0
+ local i j l sec blanks line
+ local -a arbtt_lines
if [[ ! -e ~/.arbtt/capture.log ]]; then
sleep 5
fi
- # https://stackoverflow.com/questions/56486272/how-to-concat-multiple-fields-to-same-line-with-jq
- arbtt-dump -l 30 -t json | jq -r '.[] | [ ( .inactive / 1000 | floor ) , ( .windows[] | select (.active == true) |.title) ] | @tsv' \
- | tac | while read -r sec l; do
- if (( i % 6 == 0 && i >= 2 )); then
- echo "## $(( i / 6 + 1 )) ##"
- fi
- if (( sec > 10 )); then
- printf "%3d %s\n" $sec "$l"
- else
- printf " %s\n" "$l"
- fi
- i=$(( i + 1 ))
+ blanks=$(( LINES - 34 ))
+ for (( i=0; i < blanks; i++ )); do
+ echo
done
+
+ {
+ i=0
+ j=0
+ # https://stackoverflow.com/questions/56486272/how-to-concat-multiple-fields-to-same-line-with-jq
+ arbtt_lines=$(arbtt-dump -l 30 -t json | \
+ jq -r '.[] | [ ( .inactive / 1000 | floor ) , ( .windows[] | select (.active == true) |.title) ] | @tsv' | tac)
+ for line in "${arbtt_lines[@]}"; do
+ read -r sec l <<<"$line"
+ if (( j >= LINES )); then
+ break
+ fi
+ if (( i % 6 == 0 && i >= 2 )); then
+ j=$(( j + 1 ))
+ echo "## $(( i / 6 + 1 )) ##"
+ fi
+ if (( sec > 10 )); then
+ printf "%3d %s\n" $sec "$l" | sed -r "s/^(.{$COLUMNS}).*/\1/"
+ else
+ printf " %s\n" "$l" | sed -r "s/^(.{$COLUMNS}).*/\1/"
+ fi
+ i=$(( i + 1 ))
+ j=$(( j + 1 ))
+ done
+ while (( j < 34 && j < LINES )); do
+ echo
+ j=$(( j + 1 ))
+ done
+ } | tac
}
arbttlog() {
popd
}
+
+# Tail all recent prof logs. Copying from profanity has unwanted line breaks
+# especially for links.
+profr() {
+ case $HOSTNAME in
+ kd)
+ profr-local
+ ;;
+ *)
+ ssh b8.nz profr-local
+ ;;
+ esac
+}
+
+profr-local() {
+ local d0 d1
+ local -a files
+ d0="$(date +%Y_%m_%d).log"
+ d1="$(date -d '1 day ago' +%Y_%m_%d).log"
+ ngset
+ files=(/d/p/profanity/chatlogs/iank_at_fsf.org/{*,rooms/*}/{$d0,$d1})
+ ngreset
+ if (( ${#files[@]} > 0 )); then
+ cat "${files[@]}" | sort | tail -n 40
+ fi
+}
+
+
# Tail pms in the last day, for the case where we restart profanity and
# didn't check for pms beforehand. Assume the most recent logs are on kd.
# If that isn't the case, use prof-recent-local
;;
esac
}
-
prof-recent-local() {
local d dates date files f
# consider making the day count passed by parameter. note: this works: $(date -d '2 day ago' +%Y_%m_%d)
shopt -s nullglob
shopt -s dotglob
+tmp_focus1=$(mktemp)
+tmp_focus2=$(mktemp)
+
mins=0
half_hours=0
-fast_blocks=30
start=$EPOCHSECONDS
domins=false
printf '['
+ if [[ -e /dev/shm/iank-status && ! -e /tmp/quiet-status ]]; then
+ ps_char=
+ eval "$(< /dev/shm/iank-status)"
+ fi
+
+ touch --date="10 minutes ago" $tmp_focus1
+ touch --date="30 minutes ago" $tmp_focus2
+ f=/tmp/focus-last-input
+
+ # We output a reminder to do input to the focus app if we haven't done
+ # it less 10 minutes ago (but dont bother if its been more than 30
+ # minutes, maybe we aren't running it anymore.)
+ if [[ -e $f && $tmp_focus2 -ot $f && $tmp_focus1 -nt $f ]]; then
+ ps_char="=======FOCUS====== $ps_char"
+ fi
+
+
+ printf '{ "name":"status", "color":"#ED297D", "full_text": "%s' "$ps_char"
+ printf '"},'
+
if [[ $start2 ]]; then
time2=$((EPOCHSECONDS - start2))
# there are 9 spark levels, 1/9 = .111.... In order to keep it in bash math, we upscale
# the number and divide by 111, 3 digits is good enough accuracy.
- spark_index="$(( (1000000 -($EPOCHSECONDS - $day_start)*1000000 / (16*60*60) ) % 1000 / 111 ))"
+ spark_index="$(( (1000000 -(EPOCHSECONDS - day_start)*1000000 / (16*60*60) ) % 1000 / 111 ))"
spark=" ▁▂▃▄▅▆▇█"
# note: 960 minutes, so 10 minutes is about 1%
day_thousandth=$(( 1000 - (EPOCHSECONDS - day_start)*1000 / (16*60*60) ))
read -r -t 3 line ||:
done
fi
+
+rm -f $tmp_focus1 $tmp_focus2