Skip to content

Commit bdcdfeb

Browse files
committed
This tmux alert system didn't work as nicely as I imagined
1 parent b6e1a43 commit bdcdfeb

19 files changed

Lines changed: 376 additions & 515 deletions

‎bin/omarchy‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ GROUP_DESCRIPTIONS[sudo]="Sudo configuration helpers"
8181
GROUP_DESCRIPTIONS[system]="System status, reboot, shutdown, logout, and lock"
8282
GROUP_DESCRIPTIONS[tailscale]="Tailscale helpers"
8383
GROUP_DESCRIPTIONS[theme]="Theme management"
84-
GROUP_DESCRIPTIONS[tmux]="Tmux session helpers"
8584
GROUP_DESCRIPTIONS[toggle]="Toggle Omarchy features"
8685
GROUP_DESCRIPTIONS[transcode]="Image and video transcoding"
8786
GROUP_DESCRIPTIONS[tui]="Terminal UI launchers"

‎bin/omarchy-menu-keybindings‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ prioritize_entries() {
418418
if (match(line, /Toggle workspace gaps/)) prio = 39
419419
if (match(line, /Toggle nightlight/)) prio = 40
420420
if (match(line, /Toggle locking/)) prio = 41
421-
if (match(line, /Jump to waiting Tmux pane/)) prio = 42
422421
if (match(line, /group/)) prio = 94
423422
if (match(line, /Scroll active workspace/)) prio = 95
424423
if (match(line, /Cycle to/)) prio = 96

‎bin/omarchy-shell‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ fi
4040
[[ -n ${OMARCHY_PATH:-} ]] || fail "OMARCHY_PATH is not set"
4141
[[ -f $OMARCHY_PATH/shell/shell.qml ]] || fail "omarchy-shell config not found: $OMARCHY_PATH/shell/shell.qml"
4242

43-
# qs matches instances by display, and tmux run-shell strips WAYLAND_DISPLAY
44-
# from hooks, so recover it from the compositor socket when it is missing.
43+
# qs matches instances by display, and a caller from outside the session (an
44+
# ssh or TTY omarchy-restart-shell, and the migrations it runs for) has none,
45+
# so recover it from the compositor socket.
4546
if [[ -z ${WAYLAND_DISPLAY:-} ]]; then
4647
socket=$(ls -t "${XDG_RUNTIME_DIR:-/run/user/$UID}"/wayland-[0-9]* 2>/dev/null | grep -v '\.lock$' | head -n1)
4748
[[ -n $socket ]] && export WAYLAND_DISPLAY=${socket##*/}

‎bin/omarchy-tmux-alert‎

Lines changed: 0 additions & 140 deletions
This file was deleted.

‎config/tmux/tmux.conf‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ set -ag terminal-features "xterm-kitty:extkeys"
8181
set -as terminal-features ",*:clipboard"
8282
set -sg escape-time 10
8383

84-
# Alerts
85-
set-hook -g alert-bell 'run-shell -b "omarchy-shell -q omarchy.indicators refresh"'
86-
set-hook -g alert-activity 'run-shell -b "omarchy-shell -q omarchy.indicators refresh"'
87-
set-hook -g alert-silence 'run-shell -b "omarchy-shell -q omarchy.indicators refresh"'
88-
set-hook -g after-select-window 'run-shell -b "omarchy-tmux-alert track #{window_id} #{window_activity}"'
89-
set-hook -g client-session-changed 'run-shell -b "omarchy-tmux-alert track #{window_id} #{window_activity}"'
90-
set-hook -g client-focus-out[100] 'run-shell -b "omarchy-tmux-alert track #{window_id} #{window_activity}"'
91-
set-hook -g client-focus-in[100] 'run-shell -b "omarchy-tmux-alert track #{window_id} #{window_activity}"'
92-
9384
# Status bar
9485
set -g status-position top
9586
set -g status-interval 5

‎default/hypr/bindings/utilities.lua‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ o.bind("SUPER + ESCAPE", "System menu", "omarchy-menu toggle system")
88
o.bind("XF86PowerOff", "Power menu", "omarchy-menu toggle system", { locked = true })
99
o.bind("SUPER + K", "Show key bindings", "omarchy-menu-keybindings")
1010
o.bind("SUPER + ALT + K", "Show Tmux key bindings", "omarchy-menu-tmux-keybindings")
11-
o.bind("SUPER + CTRL + J", "Jump to waiting Tmux pane", "omarchy-tmux-alert focus")
1211
o.bind("XF86Calculator", "Calculator", "gnome-calculator")
1312

1413
o.bind_toggle("SUPER + SHIFT + SPACE", "Toggle top bar", "bar")

‎migrations/1784849592.sh‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎migrations/1784955584.sh‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎migrations/1785189600.sh‎

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
echo "Remove the tmux alert hooks and its bar indicator"
2+
3+
tmux_config="$HOME/.config/tmux/tmux.conf"
4+
5+
# Drop only the hooks Omarchy installed, wherever the migrations that wrote
6+
# them left them, and only the blank run around what goes: every other line
7+
# comes through untouched.
8+
if [[ -f $tmux_config ]]; then
9+
tmp=$(mktemp)
10+
11+
if awk '
12+
function flush(count, i) { for (i = 0; i < count; i++) print "" }
13+
14+
function keep(line) {
15+
if (dropped) { if (printed && blanks) print "" }
16+
else flush(blanks)
17+
18+
blanks = 0
19+
dropped = 0
20+
printed = 1
21+
print line
22+
}
23+
24+
# The heading only belongs to the block when a removed hook follows it.
25+
/^[[:space:]]*# Alerts$/ && header == "" { header = $0; next }
26+
27+
/^[[:space:]]*set-hook -g alert-(bell|activity|silence) .*omarchy\.indicators refresh/ ||
28+
/^[[:space:]]*set-hook -g (after-select-window|client-session-changed|client-focus-(in|out))(\[[0-9]+\])? .*(omarchy-tmux-alert track|omarchy\.indicators refresh)/ {
29+
header = ""
30+
dropped = 1
31+
next
32+
}
33+
34+
/^[[:space:]]*$/ {
35+
if (header != "") { keep(header); header = "" }
36+
blanks++
37+
next
38+
}
39+
40+
{
41+
if (header != "") { keep(header); header = "" }
42+
keep($0)
43+
}
44+
45+
END {
46+
if (header != "") keep(header)
47+
if (!dropped) flush(blanks)
48+
}
49+
' "$tmux_config" >"$tmp"; then
50+
if ! cmp -s "$tmp" "$tmux_config"; then
51+
# Write through the path instead of replacing it, so a tmux.conf
52+
# symlinked out of a dotfiles repo keeps pointing where it pointed.
53+
cat "$tmp" >"$tmux_config"
54+
omarchy-restart-tmux
55+
fi
56+
else
57+
echo "Could not rewrite $tmux_config; remove the tmux alert hooks by hand."
58+
fi
59+
60+
rm -f "$tmp"
61+
fi
62+
63+
# A running server keeps its hooks as options, so sourcing a config that no
64+
# longer sets them leaves every one of them firing at the deleted command.
65+
# Unset by the exact name and index tmux reports, which leaves hooks the user
66+
# added at other indexes alone.
67+
if tmux has-session 2>/dev/null; then
68+
while read -r hook; do
69+
[[ -n $hook ]] || continue
70+
tmux set-hook -gu "$hook" 2>/dev/null || true
71+
done < <(tmux show-hooks -g 2>/dev/null |
72+
awk '$0 ~ /omarchy-tmux-alert|omarchy\.indicators refresh/ { print $1 }')
73+
74+
# The removed track subcommand stamped this on every window it saw.
75+
while read -r window; do
76+
[[ -n $window ]] || continue
77+
tmux set-option -wqu -t "$window" @omarchy_unfocused_activity 2>/dev/null || true
78+
done < <(tmux list-windows -a -F '#{window_id}' 2>/dev/null)
79+
fi
80+
81+
# Only a hand-picked indicator list names TmuxAlert; the default list lives in
82+
# the widget. An emptied list would read as "show them all", so a widget that
83+
# has nothing left to show goes with it.
84+
config_file="$HOME/.config/omarchy/shell.json"
85+
86+
if [[ -s $config_file ]] && grep -q 'TmuxAlert' "$config_file"; then
87+
tmp=$(mktemp)
88+
89+
if jq '
90+
def entry_id:
91+
if type == "string" then . elif type == "object" then (.id // "") else "" end;
92+
93+
def without_tmux_alert: map(select(entry_id != "TmuxAlert"));
94+
95+
def stripped($key):
96+
if (.[$key] | type) == "array" then .[$key] |= without_tmux_alert else . end;
97+
98+
# The list the widget actually reads: "indicators" is the older spelling of
99+
# "items", and either one empty means "show the default set".
100+
def picked:
101+
if (.items | type) == "array" and (.items | length) > 0 then .items
102+
elif (.indicators | type) == "array" and (.indicators | length) > 0 then .indicators
103+
else null end;
104+
105+
def cleaned:
106+
if type == "object" and .id == "omarchy.indicators" then stripped("items") | stripped("indicators") else . end;
107+
108+
def emptied:
109+
type == "object" and .id == "omarchy.indicators" and
110+
picked != null and (cleaned | picked) == null;
111+
112+
walk(if type == "array" then map(select(emptied | not)) | map(cleaned) else . end)
113+
' "$config_file" >"$tmp"; then
114+
cat "$tmp" >"$config_file"
115+
else
116+
echo "Could not rewrite $config_file; remove the TmuxAlert indicator by hand."
117+
fi
118+
119+
rm -f "$tmp"
120+
fi
121+
122+
# Nothing to restart from a TTY or over ssh, and that is no reason to stop the
123+
# rest of the queue: hand it to the post-update restart instead.
124+
omarchy-restart-shell >/dev/null 2>&1 || omarchy-state set restart-shell-required

0 commit comments

Comments
 (0)