omarchy-restart-shell now kills by config dir via quickshell kill and relaunches with --no-duplicate, polling kill until every instance is gone since kill returns without waiting and -n silently exits if one remains. The locked-session refusal reads Hyprland monitor state alone, which covers a hung shell holding the lock; the redundant shell IPC probe, availability guards, and omarchy-shell path indirection are gone. Shell IPC calls now time out (2s default, OMARCHY_SHELL_IPC_TIMEOUT to override) so probing an unresponsive shell fails fast instead of hanging the caller. omarchy-hyprland-launch checks dispatch output for "ok" rather than the exit code, which is 0 even on Lua errors, so a failed dispatch falls through to the bash -lc fallback instead of silently launching nothing. The Quattro upgrade cutover delegates to omarchy-restart-shell instead of carrying its own copy of the lock check, pkill, and readiness loop. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
41 lines
1.4 KiB
Bash
Executable File
41 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Restart the Omarchy shell
|
|
# omarchy:examples=omarchy restart shell
|
|
|
|
CONFIG_DIR="$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
|
|
|
|
if [[ $(hyprctl -j monitors 2>/dev/null) == *'"LOCK"'* ]]; then
|
|
echo "Refusing to restart Omarchy shell while the session is locked." >&2
|
|
exit 1
|
|
fi
|
|
|
|
for (( attempt = 0; attempt < 50; attempt++ )); do
|
|
quickshell kill -p "$CONFIG_DIR" --any-display >/dev/null 2>&1 || break
|
|
sleep 0.1
|
|
done
|
|
|
|
if (( attempt == 50 )); then
|
|
echo "Could not stop all Omarchy shell instances." >&2
|
|
exit 1
|
|
fi
|
|
|
|
printf -v launch_command 'setsid quickshell -n -p %q >/dev/null 2>&1 &' "$CONFIG_DIR"
|
|
omarchy-hyprland-launch "$launch_command"
|
|
|
|
for (( attempt = 0; attempt < 20; attempt++ )); do
|
|
OMARCHY_SHELL_IPC_TIMEOUT=0.5s omarchy-shell shell ping >/dev/null 2>&1 && exit 0
|
|
sleep 0.1
|
|
done
|
|
|
|
echo "Omarchy shell did not become ready after restart." >&2
|
|
exit 1
|