From ec1553d720cd6d91b7c1dc2754c6ad0e61a5bf5e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 25 Jul 2026 07:03:58 -0700 Subject: [PATCH] Let tmux alerts actually reach the bar The tmux alert hooks fire omarchy-shell through run-shell, and run-shell builds its own environment rather than passing the server's along, so the hook ran without WAYLAND_DISPLAY. qs matches instances by display, so every refresh from a bell died at "omarchy-shell is not running", which -q then swallowed by design. That left the indicator with no way to turn itself on. Its five second poll only runs while the indicator is already active, so an alert raised after startup was invisible until the shell happened to restart with the window still flagged. The icon appeared roughly never. Recovering the display from the socket in XDG_RUNTIME_DIR fixes it in the one place that needs it, and covers any other caller reaching the shell from a stripped environment rather than just the tmux hooks. Co-Authored-By: Claude Opus 5 (1M context) --- bin/omarchy-shell | 7 ++++++ test/shell.d/shell-ipc-display-test.sh | 30 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 test/shell.d/shell-ipc-display-test.sh diff --git a/bin/omarchy-shell b/bin/omarchy-shell index 93312327..5bd615a8 100755 --- a/bin/omarchy-shell +++ b/bin/omarchy-shell @@ -40,6 +40,13 @@ fi [[ -n ${OMARCHY_PATH:-} ]] || fail "OMARCHY_PATH is not set" [[ -f $OMARCHY_PATH/shell/shell.qml ]] || fail "omarchy-shell config not found: $OMARCHY_PATH/shell/shell.qml" +# qs matches instances by display, and tmux run-shell strips WAYLAND_DISPLAY +# from hooks, so recover it from the compositor socket when it is missing. +if [[ -z ${WAYLAND_DISPLAY:-} ]]; then + socket=$(ls -t "${XDG_RUNTIME_DIR:-/run/user/$UID}"/wayland-[0-9]* 2>/dev/null | grep -v '\.lock$' | head -n1) + [[ -n $socket ]] && export WAYLAND_DISPLAY=${socket##*/} +fi + if [[ $1 == "shell" && ( $2 == "summon" || $2 == "toggle" ) ]] && (( $# == 3 )); then set -- "$1" "$2" "$3" "{}" fi diff --git a/test/shell.d/shell-ipc-display-test.sh b/test/shell.d/shell-ipc-display-test.sh new file mode 100755 index 00000000..57327a75 --- /dev/null +++ b/test/shell.d/shell-ipc-display-test.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -euo pipefail + +source "$(dirname "$0")/base-test.sh" + +test_dir=$(mktemp -d) +trap 'rm -rf "$test_dir"' EXIT + +mkdir -p "$test_dir/bin" "$test_dir/run" +touch "$test_dir/run/wayland-1" "$test_dir/run/wayland-1.lock" + +cat >"$test_dir/bin/qs" <<'STUB' +#!/bin/bash +echo "display=[$WAYLAND_DISPLAY]" +STUB +chmod +x "$test_dir/bin/qs" + +export PATH="$test_dir/bin:$PATH" +export OMARCHY_PATH="$ROOT" +export XDG_RUNTIME_DIR="$test_dir/run" + +# tmux hooks run without WAYLAND_DISPLAY, and qs matches instances by display. +output=$(env -u WAYLAND_DISPLAY "$ROOT/bin/omarchy-shell" omarchy.indicators refresh) +[[ $output == "display=[wayland-1]" ]] || fail "shell ipc recovers a missing display" "$output" +pass "shell ipc recovers a missing display" + +output=$(WAYLAND_DISPLAY=wayland-9 "$ROOT/bin/omarchy-shell" omarchy.indicators refresh) +[[ $output == "display=[wayland-9]" ]] || fail "shell ipc keeps an existing display" "$output" +pass "shell ipc keeps an existing display"