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
+23 -1
View File
@@ -94,6 +94,21 @@ require_command() {
command -v "$command_name" >/dev/null 2>&1 || fail "$command_name is required"
}
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
}
section_valid() {
[[ $1 =~ ^(left|center|right)$ ]]
}
@@ -181,7 +196,14 @@ plugin_enabled() {
id=$(canonical_widget_id "$id")
omarchy-shell shell rescanPlugins >/dev/null 2>&1 || true
omarchy-shell shell setPluginEnabled "$id" "$enabled" || fail "could not update plugin; is omarchy-shell running?"
if [[ $enabled == "true" ]]; then
require_command jq
wait_for_plugin_discovery "$id" || fail "plugin '$id' was not discovered; is omarchy-shell running?"
fi
local result
result=$(omarchy-shell shell setPluginEnabled "$id" "$enabled") || fail "could not update plugin; is omarchy-shell running?"
[[ $result == "ok" ]] || fail "plugin '$id' is not known; run: omarchy plugin rescan"
if [[ $enabled == "true" && $# -gt 0 ]]; then
mutate_bar move --id "$id" "$@"