Updates routinely replace the shell's QML, and a stale process can lazy-load new files into old code. Restarting at the end of every omarchy update removes the need for migrations to restart the shell or defer one with the restart-shell-required marker: the login-time migration path already runs a fresh shell that hot-reloads shell.json. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
48 lines
1.5 KiB
Bash
48 lines
1.5 KiB
Bash
echo "Add the model usage widget to the bar"
|
|
|
|
# The widget is now in the default layout. It draws nothing until a provider
|
|
# reports usage — Panel.qml is `visible: providers.length > 0`, and Main.qml
|
|
# only counts a provider that is enabled *and* has recorded prompts, sessions,
|
|
# active days, or a rate limit. So adding it to every existing bar is free:
|
|
# machines without Claude Code or Codex never see it.
|
|
|
|
config_file="$HOME/.config/omarchy/shell.json"
|
|
|
|
if [[ -s $config_file ]] && omarchy-cmd-present jq; then
|
|
tmp=$(mktemp)
|
|
jq '
|
|
def entry_id:
|
|
if type == "string" then
|
|
.
|
|
elif type == "object" then
|
|
(.id // "")
|
|
else
|
|
""
|
|
end;
|
|
|
|
def has_widget($id):
|
|
[(.bar.layout // {}) | to_entries[] | .value | select(type == "array") | .[] | entry_id]
|
|
| any(. == $id);
|
|
|
|
def insert_after($anchor; $entry):
|
|
if type != "array" then
|
|
[$entry]
|
|
else
|
|
([range(0; length) as $i | select((.[$i] | entry_id) == $anchor) | $i][0]) as $anchor_index |
|
|
if $anchor_index == null then
|
|
[$entry] + .
|
|
else
|
|
.[0:$anchor_index + 1] + [$entry] + .[$anchor_index + 1:]
|
|
end
|
|
end;
|
|
|
|
# Respect a bar the user already curated: only place the widget when it is
|
|
# absent from every section, never a second copy.
|
|
if has_widget("omarchy.model-usage") then
|
|
.
|
|
else
|
|
.bar.layout.right |= insert_after("omarchy.tray"; { id: "omarchy.model-usage" })
|
|
end
|
|
' "$config_file" >"$tmp" && mv "$tmp" "$config_file" || rm -f "$tmp"
|
|
fi
|