fix: .party-notify uses PARTY_TMUX, not bare tmux from PATH

This commit is contained in:
veg 2026-07-04 09:25:27 +00:00
parent fc366f48fa
commit 7d95850461
2 changed files with 23 additions and 3 deletions

15
party
View file

@ -441,14 +441,23 @@ tmux_party_setup_server() {
# keeps it out of typical `ls` listings. The per-party private dir
# hosts at most one socket so a fixed name is safe.
notify_script="${sock%/*}/.party-notify"
cat > "$notify_script" <<'EOF'
# Two heredocs: the first (expanding) pins the tmux binary the party
# was hosted with — a bare `tmux` from the server's PATH may be a
# different, older binary than $PARTY_TMUX, which is the whole reason
# PARTY_TMUX exists. The second (quoted) is the static body. A
# PARTY_TMUX containing a double quote or $ would break the pin;
# that's accepted — it's the host's own env var on their own party.
cat > "$notify_script" <<EOF
#!/bin/sh
tmux="$PARTY_TMUX"
EOF
cat >> "$notify_script" <<'EOF'
# Auto-generated by party. Fan a display-message out to every client
# of the party server. Args: $1 = socket, $2 = client_user, $3 = "joined"|"left"
sock="$1"; user="$2"; verb="$3"
tmux -S "$sock" list-clients -F '#{client_name}' 2>/dev/null \
"$tmux" -S "$sock" list-clients -F '#{client_name}' 2>/dev/null \
| while read -r c; do
tmux -S "$sock" display-message -c "$c" "$user $verb the party" 2>/dev/null || :
"$tmux" -S "$sock" display-message -c "$c" "$user $verb the party" 2>/dev/null || :
done
EOF
chmod 0755 "$notify_script"