pkill -fxA '/bin/bash /usr/local/bin/prof-notify' ||:
-while read -r line; do
+while true; do
+ read -r line ||:
+ #echo "prof-notify debug line: $line"
+
# check that the profanity window is not focused
- if ! i3-check-profanity &>/dev/null; then
+ if [[ $line ]] && ! i3-check-profanity &>/dev/null; then
# the profanity tag makes it so new notification replaces old.
- dunstify -h string:x-dunst-stack-tag:profanity $line
+ dunstify -h string:x-dunst-stack-tag:profanity -- "$line"
fi
done
fi
# -n or else it competes with the other ssh for reading stdin.
# -l iank is just a safety measure against misconfig/temporary config in .ssh/config.
- ssh -l iank -n $remote tail -n0 -qF /home/iank/.local/share/profanity/prof-tail.log | prof-notify &
+ ssh -l iank -n $remote -- prof-tail -r | prof-notify &
ssh -l iank -t $remote tmux -L profanity a ||:
builtin kill %% &> /dev/null ||:
if (( EPOCHSECONDS > start + 600 )); then
# See the License for the specific language governing permissions and
# limitations under the License.
-
set -e; . /usr/local/lib/bash-bear; set +e
+remote=false
+if [[ $1 == -r ]]; then
+ remote=true
+ shift
+fi
+
+debug=false
+if [[ $1 == -d ]]; then
+ debug=true
+ shift
+fi
+
+
+pkill -fA '^/bin/bash /usr/local/bin/prof-tail' ||:
+
# kill 0 doesn't seem to be documented in man bash, but it kills the
# background processes.
jtuttle
)
+tail-cmd() {
+ # example room chat log:
+ #
+ # 2025-11-25T07:56:12.307132-05 - zoe: morning here for an hour
+ #
+ # example pm chat log:
+ #
+ # 2025-11-02T16:29:27.100202-05 - me: ok. good luck
+ # 2025-11-02T17:42:02.547790-05 - zoe@fsf.org: oh damn
+
+ # note: man timeout says 124 is when timeout times out.
+ # for debugging, add test2 to the room list and use jtuttle with pidgin.
+ timeout $secs_till_midnight tail -n0 -qF \
+ $logdir/rooms/{sys-private,office,operations}_at_conference.fsf.org/$log_today ${user_logs[@]} 2>/dev/null \
+ | sed -urn "/$pre iank: /d;s/$pre ([^@ ]+: .*\biank\b.*)/\1/p;s/$pre ([^@:]+)@.*/pm: \1/p" || [[ ${PIPESTATUS[0]} == 124 ]]
+
+}
+
+notify-cmd() {
+ local line="$1"
+ if $debug; then
+ echo "prof-notify debug line: $line"
+ fi
+
+ # check that the profanity window is not focused
+ if [[ $line ]] && ! i3-check-profanity &>/dev/null; then
+ dunstify -h string:x-dunst-stack-tag:profanity -- "$line"
+ fi
+}
pre="^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}-[0-9]{2} -"
user_logs+=($logdir/${u}_at_fsf.org/$log_today)
done
- # example room chat log:
- #
- # 2025-11-25T07:56:12.307132-05 - zoe: morning here for an hour
- #
- # example pm chat log:
- #
- # 2025-11-02T16:29:27.100202-05 - me: ok. good luck
- # 2025-11-02T17:42:02.547790-05 - zoe@fsf.org: oh damn
-
- # psuedocode simplified strategy:
- # tail room_logs | grep -v '^pre iank:' | grep iank | tail - pm_logs | grep -v "^$pre me:"
- # shellcheck disable=SC2046 # intentional
- timeout --foreground $secs_till_midnight tail -n0 -qF \
- $logdir/rooms/*/$log_today 2>/dev/null \
- | sed -rn "/$pre iank: /d;s/$pre /room: /;/\biank\b/p" \
- | tail -n0 -qf --retry -- - ${user_logs[@]} \
- | sed -rn "s/$pre ([^@:]+)@.*/pm: \1/p;/^room: /p" || [[ ${PIPESTATUS[0]} == 124 ]]
- # note: man timeout says 124 is when timeout times out.
+ if $remote; then
+ tail-cmd
+ else
+ tail-cmd | while :; do read -r l; notify-cmd "$l"; done
+ fi
sleep 2
done
+++ /dev/null
-[Unit]
-Description=profanity log tail for notifications
-After=gpg-agent.service
-
-# This service exists because killing leftover prof-tail would still
-# leave around its subprocesses. I think its cuz the signal doesn't
-# propogate, and it would if i killed the process group, but i don't
-# know how, so just do this and have 1 process which tails a single
-# file.
-#
-#
-[Service]
-ExecStart=/usr/local/bin/prof-tail
-StandardOutput=truncate:/home/iank/.local/share/profanity/prof-tail.log
-
-[Install]
-WantedBy=default.target