2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
9 # Copyright 2024 Ian Kelling
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
15 # http://www.apache.org/licenses/LICENSE-2.0
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
23 set -e; .
/usr
/local
/lib
/bash-bear
; set +e
25 # kill 0 doesn't seem to be documented in man bash, but it kills the
26 # background processes.
27 # https://unix.stackexchange.com/questions/67532/what-does-kill-0-do-actually/67552
46 # start emacs daemon for profanity if it doesnt exist.
47 if ! pgrep
-f '^emacs --daemon=profanity$' &>/dev
/null
; then
48 emacs
--daemon=profanity
&>/dev
/null
53 midnight
=$
(date -d '00:00:00 tomorrow' +%s
)
54 secs_till_midnight
=$
(( midnight
- EPOCHSECONDS
))
55 log_today
=$
(date '+%Y_%m_%d').log
56 logdir
=/home
/iank
/.local
/share
/profanity
/chatlogs
/iank_at_fsf.org
58 # when this fails, it has PIPESTATUS: 124 0 1 0 0, which seems to end up with 1 as the overall code, which is not what
59 # i expected. todo: investigate if and why that is, and narrow the ||:
60 # shellcheck disable=SC2046 # intentional
61 timeout
--foreground $secs_till_midnight tail -n0 -qF \
62 $
(for u
in ${xmpp_users[@]}; do echo $logdir/${u}_at_fsf.org
/$log_today; done) 2>/dev
/null \
63 |
awk '$3 != "me:" {print $3; fflush()}' |
sed -u 's/^/pm /;s/@.*//' ||
: &
65 timeout
--foreground $secs_till_midnight tail -n0 -qF \
66 $logdir/rooms
/*/$log_today 2>/dev
/null \
67 |
awk '$3 != "iank:"' |
grep -i '\biank\b' |
awk '{print $3; fflush()}' |
sed 's/^/room /;s/@.*//' ||
: