* Instantiate only the current orientation's indicator tree Indicators.qml built both the horizontal Row and the vertical Column and toggled them with `visible`, so every indicator existed twice per bar, and so did every process an indicator spawns: Dictation.qml ran two `voxtype status --follow` per monitor. On a six-monitor bar that is 72 indicator instances and twelve followers for six visible icons, and each instance registers a click target and re-syncs the active-indicator model as its state resolves at startup. A Loader now instantiates the tree that matches `root.vertical`. Each tree is wrapped in an Item that keeps the stock explicit implicit-size expressions, so the root's size still follows the blocks synchronously; a bare positioner only updates its implicit size on polish, which the indicator contract test's center-hover check catches. Measured on a six-monitor, 23-widget bar (three runs each, `omarchy restart shell`): time from "Configuration Loaded" to "polkit agent registered" 19.8-20.3s -> 15.5-15.7s, quickshell CPU 29-30s -> 24-25s, voxtype followers 12 -> 6. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Coalesce plugin API resyncs and key bar object ownership by target Every WidgetButton registers itself as a bar click target when it is created. registerClickTarget replaced the clickTargets array, the change handler ran syncAllPluginBarApiObjects() inline, and that walked every plugin API times every click target times a linear scan of pluginObjectOwners in pluginObjectRecord. Startup is a few hundred registrations, so the cost is quadratic in bar size and multiplied by the number of monitors: a six-monitor, 23-widget bar spent 16-20 seconds of pegged QML thread before it was populated, and an 8-second qmlprofiler capture showed 1.36 million pluginOwnsBarObject calls and 46-71ms per registration. - pluginObjectOwners is a Map keyed by target, so pluginObjectRecord, markPluginObject, unmarkPluginObject and releasePluginObjects are O(1) per object. Nothing outside Bar.qml read the array. - The activePopout, clickTargets and layoutConfig change handlers schedule one resync per event-loop turn through Qt.callLater, the way onModuleSlotsChanged already defers prunePluginBarApis. bindPluginBarApi still syncs a brand-new API inline, and requestPluginPopout and releasePluginPopout sync the owning API inline, so a plugin never reads a stale API on its own actions. - A flush serialises the layout once and hands each API its own parsed copy instead of deep-copying it once per API per sync. - ModuleSlot's cursorShape read clickTargets for every slot on every monitor (26,700 evaluations per start). It is now gated on the slot's HoverHandler, which is the only time the cursor is over it. Measured on the same bar, launching the shell from a checkout with this and the indicators change (two runs): "Configuration Loaded" to "polkit agent registered" 19.8-20.3s -> 0.70s, bar populated 1.7s after launch (from ~30s), quickshell CPU 29-30s -> 2.0s. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Wait for the old shell to exit before restarting it omarchy-restart-shell stopped the running shell with `quickshell kill` under a five-second timeout and launched the replacement as soon as the loop ended. A six-monitor bar takes 5.4-6.0 seconds to tear down (every widget button unregisters its click target on destruction, and each unregistration re-synced every plugin API), so the client timed out while the shell was still exiting, the fresh instance's no-duplicate check saw the dying one and quit, and the user was left with no bar and "Omarchy shell did not become ready after restart". Give the kill client thirty seconds, then wait, bounded, until `quickshell list` shows no instance of the session config before launching. The readiness check also waits on a sixty-second deadline instead of twenty attempts: a large bar answers ping only after its plugins have loaded, which on the stock bar was well past the old twelve-second window. Verified three consecutive restarts against the stock shell on the six-monitor machine: each returned 0 in about six seconds with exactly one instance and no "already running" in the journal. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Say what the bar's ownership Map actually saves Qt's V4 Map (ESTable::get) finds a key by scanning its keys, so ownership lookups are not O(1). The win is that a registration no longer copies the owner array and rescans it in QML. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com> Co-authored-by: Codex Medium <noreply@openai.com>
151 lines
6.3 KiB
Bash
Executable File
151 lines
6.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Restart the Omarchy shell
|
|
# omarchy:examples=omarchy restart shell
|
|
|
|
# A caller opened after dev link/unlink may disagree with the still-running
|
|
# desktop. The user manager receives Hyprland's environment at session start.
|
|
session_omarchy_path=$(systemctl --user show-environment 2>/dev/null | sed -n 's/^OMARCHY_PATH=//p' | tail -n 1)
|
|
: "${session_omarchy_path:=$OMARCHY_PATH}"
|
|
|
|
CONFIG_DIR="$session_omarchy_path/shell"
|
|
[[ -f $CONFIG_DIR/shell.qml ]] || { echo "Omarchy shell config not found: $CONFIG_DIR" >&2; exit 1; }
|
|
|
|
# Allow running from outside the session (e.g. over ssh) by deriving the
|
|
# Hyprland instance signature from the newest instance runtime dir.
|
|
if [[ -z ${HYPRLAND_INSTANCE_SIGNATURE:-} ]]; then
|
|
hypr_dir=$(find "${XDG_RUNTIME_DIR:-/run/user/$UID}/hypr" -mindepth 1 -maxdepth 1 -type d -printf '%T@ %p\n' 2>/dev/null | sort -n | tail -n 1 | cut -d' ' -f2-)
|
|
[[ -n $hypr_dir ]] && export HYPRLAND_INSTANCE_SIGNATURE=${hypr_dir##*/}
|
|
fi
|
|
|
|
# Restarting a live lock client would kill the lock screen and strand the
|
|
# session behind Hyprland's failsafe. But a LOCK session without an active
|
|
# locker — the shell died, or its crash handler re-execed a fresh instance
|
|
# that holds no lock — sits in that failsafe with no way to authenticate,
|
|
# and a restart plus re-lock is the only way back in without a reboot. So
|
|
# ask the lock service rather than merely pinging the shell: only a locker
|
|
# that reports the lock secure or in progress is worth preserving.
|
|
relock=0
|
|
if omarchy-hyprland-session-locked; then
|
|
locking=$(OMARCHY_PATH="$session_omarchy_path" OMARCHY_SHELL_IPC_TIMEOUT=0.5s omarchy-shell lock status 2>/dev/null |
|
|
jq -r '.secure or .requested' 2>/dev/null)
|
|
if [[ $locking == "true" ]]; then
|
|
echo "Refusing to restart Omarchy shell while the session is locked." >&2
|
|
exit 1
|
|
fi
|
|
relock=1
|
|
fi
|
|
|
|
# The lock plugin loads asynchronously, so a fresh shell answers ping before
|
|
# it can lock, and may even refuse early lock requests while its plugins or
|
|
# PAM config are still loading. Mirror omarchy-system-sleep-lock: request the
|
|
# lock and poll until the session reports secure, re-requesting as needed, so
|
|
# recovery never claims success while the failsafe is still up. The deadline
|
|
# is generous because slow plugin discovery delays the lock IPC target.
|
|
relock_session() {
|
|
local state deadline=$((SECONDS + 30))
|
|
|
|
while (( SECONDS < deadline )); do
|
|
state=$(OMARCHY_PATH="$session_omarchy_path" OMARCHY_SHELL_IPC_TIMEOUT=0.5s omarchy-shell lock status 2>/dev/null |
|
|
jq -r 'if .secure == true then "secure" elif .requested == true then "locking" else "idle" end' 2>/dev/null)
|
|
|
|
case $state in
|
|
secure) return 0 ;;
|
|
locking) ;;
|
|
*) OMARCHY_PATH="$session_omarchy_path" OMARCHY_SHELL_IPC_TIMEOUT=0.5s omarchy-shell lock lock >/dev/null 2>&1 ;;
|
|
esac
|
|
|
|
sleep 0.1
|
|
done
|
|
|
|
return 1
|
|
}
|
|
|
|
# A short timeout keeps an unresponsive user bus from stalling the restart;
|
|
# busctl would otherwise wait 25 seconds per probe.
|
|
notifications_ready() {
|
|
[[ $(busctl --user --timeout=1s call org.freedesktop.DBus /org/freedesktop/DBus \
|
|
org.freedesktop.DBus NameHasOwner s org.freedesktop.Notifications 2>/dev/null) == "b true" ]]
|
|
}
|
|
|
|
# Core IPC can answer before the notification plugin has registered its bus
|
|
# name. Restore an existing notification service before update hooks or setup
|
|
# invitations send their one-time toasts; a disabled service need not appear.
|
|
notifications_were_running=0
|
|
if notifications_ready; then
|
|
notifications_were_running=1
|
|
fi
|
|
|
|
# Each kill stops the oldest matching instance and only returns once it has
|
|
# fully exited. A large bar can take longer than a few seconds to tear down,
|
|
# so the client gets time to see that through, and the wait below covers a
|
|
# client that timed out anyway: the fresh shell refuses to start next to a
|
|
# still-dying instance (-n), which is how a restart used to end with no bar.
|
|
while timeout 30 quickshell kill -p "$CONFIG_DIR" --any-display >/dev/null 2>&1; do :; done
|
|
|
|
shell_instance_running() {
|
|
quickshell list -a -j 2>/dev/null |
|
|
jq -e --arg dir "$CONFIG_DIR/" 'any(.[]; .config_path | startswith($dir))' >/dev/null 2>&1
|
|
}
|
|
|
|
deadline=$((SECONDS + 30))
|
|
while (( SECONDS < deadline )) && shell_instance_running; do
|
|
sleep 0.1
|
|
done
|
|
|
|
# Spawn from Hyprland so the shell inherits the canonical session environment,
|
|
# not transient variables from a terminal, SSH connection, or development tool.
|
|
hyprctl dispatch 'hl.dsp.exec_cmd("omarchy-launch-shell")' >/dev/null
|
|
|
|
shell_ready=0
|
|
# The shell answers once its plugins have loaded, which on a large bar is
|
|
# well past ten seconds, so wait on a deadline rather than a fixed handful
|
|
# of attempts.
|
|
deadline=$((SECONDS + 60))
|
|
while (( SECONDS < deadline )); do
|
|
if OMARCHY_PATH="$session_omarchy_path" OMARCHY_SHELL_IPC_TIMEOUT=0.5s omarchy-shell shell ping >/dev/null 2>&1; then
|
|
shell_ready=1
|
|
break
|
|
fi
|
|
sleep 0.1
|
|
done
|
|
if (( shell_ready == 0 )); then
|
|
echo "Omarchy shell did not become ready after restart." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# The session stays compositor-locked after the old lock client died, so
|
|
# re-acquire the lock and let the user authenticate out of it. This comes
|
|
# first and depends on nothing else: a user stranded behind the failsafe must
|
|
# not wait on the notification plugin, which may be slow or absent.
|
|
if (( relock )) && ! relock_session; then
|
|
echo "Omarchy shell restarted, but the session lock was not re-secured." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Core IPC answers before the notification plugin has registered its bus
|
|
# name, so wait for it separately before one-time toasts are sent.
|
|
if (( notifications_were_running )); then
|
|
notifications_restored=0
|
|
for (( attempt = 0; attempt < 20; attempt++ )); do
|
|
if notifications_ready; then
|
|
notifications_restored=1
|
|
break
|
|
fi
|
|
sleep 0.1
|
|
done
|
|
if (( notifications_restored == 0 )); then
|
|
echo "Omarchy shell restarted, but its notification service did not become ready." >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Invitation toasts (like Voxtype/fingerprint setup) die with the old
|
|
# shell, and their notify-send waiters hang forever: the dying server
|
|
# never emits NotificationClosed. A still-running omarchy-*-invitation
|
|
# unit is therefore an unanswered invitation — re-run it so its toast
|
|
# reappears on the new shell. Answered invitations have already exited
|
|
# and been collected, so the glob no longer matches them.
|
|
systemctl --user try-restart 'omarchy-*-invitation.service' 2>/dev/null || true
|
|
exit 0
|