From 4ba4a53209cdbd96dfba0bb8ef856680b990033e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 28 Sep 2026 10:25:13 +0200 Subject: [PATCH] Nudge running Hunk sessions to pick up new theme colors (#13518) Co-authored-by: Claude Opus 5.5 --- bin/omarchy-theme-set | 1 + bin/omarchy-theme-set-hunk | 14 ++++++++++++++ test/cli | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100755 bin/omarchy-theme-set-hunk diff --git a/bin/omarchy-theme-set b/bin/omarchy-theme-set index dff1501c..10faf872 100755 --- a/bin/omarchy-theme-set +++ b/bin/omarchy-theme-set @@ -424,6 +424,7 @@ post_theme_commands=( omarchy-restart-helix omarchy-theme-set-foot omarchy-theme-set-tmux + omarchy-theme-set-hunk omarchy-theme-set-gnome omarchy-theme-set-pi omarchy-theme-set-claude diff --git a/bin/omarchy-theme-set-hunk b/bin/omarchy-theme-set-hunk new file mode 100755 index 00000000..5c92fa7a --- /dev/null +++ b/bin/omarchy-theme-set-hunk @@ -0,0 +1,14 @@ +#!/bin/bash + +# omarchy:summary=Tell running Hunk sessions to pick up the new terminal colors +# omarchy:hidden=true + +# Hunk's default terminal theme re-reads the terminal palette on SIGWINCH. Terminals reload +# their colors in parallel with this hook, so nudge once now and once after they have settled; +# Hunk only repaints when the palette actually changed. + +if pgrep -x hunk >/dev/null; then + pkill -WINCH -x hunk + sleep 1 + pkill -WINCH -x hunk +fi diff --git a/test/cli b/test/cli index 1643d2db..4081921c 100755 --- a/test/cli +++ b/test/cli @@ -550,6 +550,33 @@ TMUX_LOG="$PI_TMPDIR/tmux.log" PATH="$FAKE_BIN:$ROOT/bin:$PATH" HOME="$PI_TMPDIR grep -q 'set-environment -g COLORFGBG 0;15' "$PI_TMPDIR/tmux.log" || fail "tmux sync reads mode from colors.toml" pass "tmux sync reads mode from colors.toml" +cat >"$FAKE_BIN/pgrep" <<'EOF' +#!/bin/bash +[[ -n $HUNK_RUNNING ]] +EOF +chmod +x "$FAKE_BIN/pgrep" + +cat >"$FAKE_BIN/pkill" <<'EOF' +#!/bin/bash +echo "$*" >>"${PKILL_LOG:-/dev/null}" +EOF +chmod +x "$FAKE_BIN/pkill" + +cat >"$FAKE_BIN/sleep" <<'EOF' +#!/bin/bash +exit 0 +EOF +chmod +x "$FAKE_BIN/sleep" + +HUNK_RUNNING=1 PKILL_LOG="$PI_TMPDIR/pkill.log" PATH="$FAKE_BIN:$ROOT/bin:$PATH" HOME="$PI_TMPDIR" "$ROOT/bin/omarchy-theme-set-hunk" +[[ $(grep -c -- '-WINCH -x hunk' "$PI_TMPDIR/pkill.log") == "2" ]] || fail "hunk sync signals running hunk sessions" +pass "hunk sync signals running hunk sessions" + +PKILL_LOG="$PI_TMPDIR/pkill-idle.log" PATH="$FAKE_BIN:$ROOT/bin:$PATH" HOME="$PI_TMPDIR" "$ROOT/bin/omarchy-theme-set-hunk" +[[ ! -e $PI_TMPDIR/pkill-idle.log ]] || fail "hunk sync skips signaling without running hunk" +pass "hunk sync skips signaling without running hunk" +rm -f "$FAKE_BIN/pgrep" "$FAKE_BIN/pkill" "$FAKE_BIN/sleep" + cat >"$FAKE_BIN/gsettings" <<'EOF' #!/bin/bash echo "$*" >>"${GSETTINGS_LOG:-/dev/null}"