From: Ian Kelling Date: Wed, 3 Dec 2025 21:20:37 +0000 (-0500) Subject: cleanup profanity notify processes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=5de18c4f3efd1d32cfd5ad8396ed8165c66f1d77;p=distro-setup cleanup profanity notify processes --- diff --git a/distro-end b/distro-end index 13692b6..c66ce7e 100755 --- a/distro-end +++ b/distro-end @@ -1177,6 +1177,7 @@ 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 ;; *) diff --git a/filesystem/usr/local/bin/i3-chat b/filesystem/usr/local/bin/i3-chat index 563a4f7..4ed1392 100755 --- a/filesystem/usr/local/bin/i3-chat +++ b/filesystem/usr/local/bin/i3-chat @@ -24,6 +24,37 @@ i3-msg "workspace 4" if ! pgrep "^prof$" >/dev/null; then prof & fi -if ! pgrep -f '^emacs -f my-znc-all$' >/dev/null; then - irc & +# start emacs daemon for profanity if it doesnt exist. +cmd="emacsclient -s profanity -nc" +if ! pgrep -fx "$cmd" &>/dev/null; then + $cmd &>/dev/null fi + + + +# tree of profanity related processes: + +# i3-chat (ctrl+y) +# prof +# export IANK_BASHRC_RUN="prof-remote $remote" +# konsole --profile profanity +# prof-remote $remote +# ssh -n $remote tail -n0 -qF \ +# /home/iank/.local/share/profanity/prof-tail.log | prof-notify & +# ssh -t $remote tmux -L profanity a ||: + + +# distro_end, on $d_host +# systemctl --user enable --now profanity.service +# /b/ds/subdir_files/.config/systemd/user/profanity.service +# /usr/bin/tmux -L profanity new-session -d profanity +# systemctl --user enable --now prof-tail.service +# note: StandardOutput=truncate:/home/iank/.local/share/profanity/prof-tail.log +# /usr/local/bin/prof-tail +# + +# /p/profanity-config/profrc & /d/p/profanity-config: +# compose.editor=/usr/local/bin/prof-irc (alt-c) +# exec emacsclient -s profanity -a "" "$@" +# +# ... (not finished documenting) diff --git a/filesystem/usr/local/bin/prof b/filesystem/usr/local/bin/prof index 8316316..c46d82b 100755 --- a/filesystem/usr/local/bin/prof +++ b/filesystem/usr/local/bin/prof @@ -45,22 +45,3 @@ else fi -# tree of profanity related processes: - -# prof -# export IANK_BASHRC_RUN="prof-remote $remote" -# konsole --profile profanity -# prof-remote $remote -# ssh -n $remote prof-tail | prof-notify & -# prof-tail -# emacs --daemon=profanity &>/dev/null -# ssh -t $remote tmux -L profanity a ||: - - -# on $remote -# /b/ds/subdir_files/.config/systemd/user/profanity.service -# /usr/bin/tmux -L profanity new-session -d profanity - -# /p/profanity-config/profrc & /d/p/profanity-config: -# compose.editor=/usr/local/bin/prof-irc -# ... (not finished documenting) diff --git a/filesystem/usr/local/bin/prof-irc b/filesystem/usr/local/bin/prof-irc index d3ad9ba..b9dc286 100755 --- a/filesystem/usr/local/bin/prof-irc +++ b/filesystem/usr/local/bin/prof-irc @@ -26,7 +26,7 @@ # note: this is NOT in the online manual list of commands, that has got to # be a bug. -# This, along with changes to emacs init file and prof-remote allows us +# This, along with changes to emacs init file in mymu4e.el and prof-remote allows us # to press alt-c in profanity to send the current text to #fsfsys. exec emacsclient -s profanity -a "" "$@" diff --git a/filesystem/usr/local/bin/prof-notify b/filesystem/usr/local/bin/prof-notify index a748328..ebcc28e 100755 --- a/filesystem/usr/local/bin/prof-notify +++ b/filesystem/usr/local/bin/prof-notify @@ -22,6 +22,10 @@ set -e; . /usr/local/lib/bash-bear; set +e +# -A = --ignore-ancestors (dont kill ourselves) +pkill -fxA '/bin/bash /usr/local/bin/prof-notify' ||: + + while read -r line; do # check that the profanity window is not focused if ! i3-check-profanity &>/dev/null; then diff --git a/filesystem/usr/local/bin/prof-remote b/filesystem/usr/local/bin/prof-remote index d7363fe..f648656 100755 --- a/filesystem/usr/local/bin/prof-remote +++ b/filesystem/usr/local/bin/prof-remote @@ -32,7 +32,7 @@ while true; do ssh -n $remote fi # -n or else it competes with the other ssh for reading stdin. - ssh -n $remote prof-tail | prof-notify & + ssh -n $remote tail -n0 -qF /home/iank/.local/share/profanity/prof-tail.log | prof-notify & ssh -t $remote tmux -L profanity a ||: builtin kill %% &> /dev/null ||: if (( EPOCHSECONDS > start + 600 )); then diff --git a/filesystem/usr/local/bin/prof-tail b/filesystem/usr/local/bin/prof-tail index 40d373c..9a9c024 100755 --- a/filesystem/usr/local/bin/prof-tail +++ b/filesystem/usr/local/bin/prof-tail @@ -20,11 +20,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# hacky way to kill off old leftover processes -pkill -O 1 -x 'prof-tail' set -e; . /usr/local/lib/bash-bear; set +e + # kill 0 doesn't seem to be documented in man bash, but it kills the # background processes. # https://unix.stackexchange.com/questions/67532/what-does-kill-0-do-actually/67552 @@ -32,29 +31,27 @@ set -e; . /usr/local/lib/bash-bear; set +e # the connection dying or killing konsole, and this has no effect on either. #trap "kill 0" EXIT +## former employees +# anoukr +# devinu +# miriam +# ruben xmpp_users=( - anoukr + andrew craigt dawnbp - devinu + ekokao gregf johnh jrasata ksiewicz michael - miriam - ruben zoe jtuttle - ekokao ) -# start emacs daemon for profanity if it doesnt exist. -if ! pgrep -f '^emacs --daemon=profanity$' &>/dev/null; then - emacs --daemon=profanity &>/dev/null -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} -" while true; do midnight=$(date -d '00:00:00 tomorrow' +%s) @@ -62,17 +59,24 @@ while true; do log_today=$(date '+%Y_%m_%d').log logdir=/home/iank/.local/share/profanity/chatlogs/iank_at_fsf.org - # 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 - # i expected. todo: investigate if and why that is, and narrow the ||: - # shellcheck disable=SC2046 # intentional - timeout --foreground $secs_till_midnight tail -n0 -qF \ - $(for u in ${xmpp_users[@]}; do echo $logdir/${u}_at_fsf.org/$log_today; done) 2>/dev/null \ - | awk '$3 != "me:" {print $3; fflush()}' | sed -u 's/^/pm /;s/@.*//' ||: & + # 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 \ - | awk '$3 != "iank:"' | grep -i '\biank\b' | awk '{print $3; fflush()}' | sed 's/^/room /;s/@.*//' ||: + | sed -rn "/$pre iank: /d;s/$pre /room: /;/\biank\b/p" \ + | tail -n0 -qF -- - $(for u in ${xmpp_users[@]}; do echo $logdir/${u}_at_fsf.org/$log_today; done) 2>/dev/null \ + | sed -rn "s/$pre ([^@:]+)@.*/pm: \1/p;/^room: /p" || [[ ${PIPESTATUS[0]} == 124 ]] + # note: man timeout says 124 is when timeout times out. - kill % - sleep 1 + sleep 2 done diff --git a/filesystem/usr/local/bin/switch-mail-host b/filesystem/usr/local/bin/switch-mail-host index fb3212d..a4c5f63 100755 --- a/filesystem/usr/local/bin/switch-mail-host +++ b/filesystem/usr/local/bin/switch-mail-host @@ -307,9 +307,11 @@ if ! $mail_only; then # But if emacs ignores the signal, let it live. pkill -xf 'emacs --daemon' ||: -if [[ -e /p/profanity-here ]]; then - systemctl disable --now profanity -fi +# iank: todo: figure this out. the only profanity service is +# a user service, so this is wrong. commented out cuz of that. +#if [[ -e /p/profanity-here ]]; then +# systemctl disable --now profanity +#fi EOF fi diff --git a/subdir_files/.config/systemd/user/prof-tail.service b/subdir_files/.config/systemd/user/prof-tail.service new file mode 100644 index 0000000..c77c8ad --- /dev/null +++ b/subdir_files/.config/systemd/user/prof-tail.service @@ -0,0 +1,17 @@ +[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 diff --git a/subdir_files/.config/systemd/user/profanity.service b/subdir_files/.config/systemd/user/profanity.service index b7b9a05..1838378 100644 --- a/subdir_files/.config/systemd/user/profanity.service +++ b/subdir_files/.config/systemd/user/profanity.service @@ -13,7 +13,6 @@ After=gpg-agent.service [Service] # tmux requirement Type=forking - # new-session is a tmux command which allows launching profanity. ExecStart=/usr/bin/tmux -L profanity new-session -d profanity