Enable plugin hot reloading for add / remove

This commit is contained in:
Ryan Hughes
2026-06-06 13:25:54 -04:00
parent 42bdf374dd
commit 92246a50fb
10 changed files with 126 additions and 21 deletions
+18 -1
View File
@@ -29,6 +29,21 @@ interactive() {
[[ -t 0 && -t 1 ]]
}
plugin_discovered() {
local id="$1" plugins
plugins=$(omarchy-shell shell listPlugins 2>/dev/null) || return 1
jq -e --arg id "$id" 'any(.[]; .id == $id)' <<<"$plugins" >/dev/null 2>&1
}
wait_for_plugin_discovery() {
local id="$1" attempt
for (( attempt = 0; attempt < 40; attempt++ )); do
plugin_discovered "$id" && return 0
sleep 0.05
done
return 1
}
PLUGIN_ID=""
FROM_SOURCE=""
ENABLE_AFTER="" # "", "true", or "false"
@@ -280,7 +295,9 @@ if [[ -z $ENABLE_AFTER ]]; then
fi
if [[ $ENABLE_AFTER == true ]]; then
if omarchy-shell shell setPluginEnabled "$m_id" true >/dev/null 2>&1; then
if ! wait_for_plugin_discovery "$m_id"; then
echo "Could not enable $m_id because omarchy-shell did not discover it yet. Enable later with: omarchy plugin enable $m_id" >&2
elif result=$(omarchy-shell shell setPluginEnabled "$m_id" true) && [[ $result == "ok" ]]; then
echo "Enabled $m_id."
if [[ $m_kinds == *bar-widget* ]]; then
echo "It was added to the bar; arrange it with: omarchy plugin bar move $m_id --section <left|center|right>"