fix profanity notifications
authorIan Kelling <ian@iankelling.org>
Fri, 19 Dec 2025 05:56:46 +0000 (00:56 -0500)
committerIan Kelling <ian@iankelling.org>
Fri, 19 Dec 2025 05:56:46 +0000 (00:56 -0500)
distro-end
filesystem/usr/local/bin/prof
filesystem/usr/local/bin/prof-notify
filesystem/usr/local/bin/prof-remote
filesystem/usr/local/bin/prof-tail
subdir_files/.config/systemd/user/prof-tail.service [deleted file]

index 496c7c5d0a9030be46e3f44a27628bdc66c92b8a..34acd4b1905a165c1c4ebfe3c908cff1d8f90272 100755 (executable)
@@ -1180,7 +1180,6 @@ case $HOSTNAME in
     ln -sfT /d/p/profanity-config ~/.config/profanity
     if [[ $HOSTNAME == "$HOST2" || ! -e /p/profanity-here ]]; then
       systemctl --user --now enable profanity
-      systemctl --user --now enable prof-tail
     fi
     ;;
   *)
index 793d09a33941ec254c37cfb2c4efd539576aa678..b7ddf7fc3e03eb974fc7e7728c5bce3638a616ea 100755 (executable)
@@ -41,7 +41,7 @@ if $dossh; then
   export IANK_BASHRC_RUN="prof-remote $remote"
   konsole --profile profanity
 else
-  prof-tail | prof-notify &
+  prof-tail &
   konsole --profile profanity -e tmux -L profanity a
 fi
 
index ebcc28e949a92b523583963df0dad584e77e8825..ef66031af1bba0cd9baf22871186ffd6982e7d9b 100755 (executable)
@@ -26,10 +26,13 @@ set -e; . /usr/local/lib/bash-bear; set +e
 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
index a34be7c4a8db89bb1cde76b380160068657ded9c..a413d56e763bf1bd822f82e6f2724dad0f411ef6 100755 (executable)
@@ -33,7 +33,7 @@ while true; do
   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
index c84d77a4765cfa0ebb1e457dc8e627210885dce2..0bf0dd59e52481b924d9fc37f9496bd367783b80 100755 (executable)
 # 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.
@@ -51,6 +65,35 @@ xmpp_users=(
   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} -"
 
@@ -64,24 +107,11 @@ while true; do
     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
diff --git a/subdir_files/.config/systemd/user/prof-tail.service b/subdir_files/.config/systemd/user/prof-tail.service
deleted file mode 100644 (file)
index c77c8ad..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-[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