fix: pin absolute script path in status-right widget

The #() body runs with the tmux server's PATH; a bare 'party' silently
broke the widget for uninstalled or non-standard-prefix hosts.
This commit is contained in:
veg 2026-07-04 09:39:45 +00:00
parent 7d95850461
commit 2ef4eb49ce
2 changed files with 23 additions and 2 deletions

19
party
View file

@ -430,6 +430,22 @@ compute_default_party_name() {
printf 'party-%s\n' "$rand"
}
# Absolute path to this script, for embedding in tmux server state that
# outlives this invocation (the status-right #() widget runs with the
# tmux server's PATH, which need not contain an installed `party`).
# $0 forms: absolute — take it; relative-with-slash — anchor to cwd;
# bare word — resolve via PATH, falling back to $0 verbatim. No `--`
# after command -v/dirname/basename: old illumos userland predates it,
# and $0 here never starts with '-'.
party_self_path() {
case "$0" in
/*) printf '%s\n' "$0" ;;
*/*) printf '%s/%s\n' "$(cd "$(dirname "$0")" && pwd)" \
"$(basename "$0")" ;;
*) command -v "$0" 2>/dev/null || printf '%s\n' "$0" ;;
esac
}
# After spawning the party server, configure status line and hooks.
# All commands run against -S "$sock". Every literal name embedded
@ -469,8 +485,9 @@ EOF
chgrp "$TMUX_PARTY_GROUP" "$notify_script"
"$PARTY_TMUX" -S "$sock" set-option -s exit-empty on
party_self=$(party_self_path)
"$PARTY_TMUX" -S "$sock" set-option -g status-right \
"party: #(party who --short --socket $sock 2>/dev/null)"
"party: #($party_self who --short --socket $sock 2>/dev/null)"
# Join/leave broadcast. Hook bodies fan a display-message out to
# every attached client of THIS server via the notify helper script.
# tmux substitutes #{client_user} before running the shell command.