diff --git a/omarchy/extensions/omarchy-menu.jsonc b/omarchy/extensions/omarchy-menu.jsonc index 07013cb..0e8db48 100644 --- a/omarchy/extensions/omarchy-menu.jsonc +++ b/omarchy/extensions/omarchy-menu.jsonc @@ -2,9 +2,9 @@ // Blob entries added to the Quickshell Omarchy menu (Super + Space). // These replace the walker/elephant menus used before Omarchy 4. - "blob": { "icon": "", "label": "Blob" }, - "blob.wallpaper": { "icon": "", "label": "Wallpaper", "action": "blob_wallpaper --menu", "description": "Pick a wallpaper from ~/wallpapers" }, - "blob.theme": { "icon": "", "label": "Theme", "action": "blob_theme --menu", "description": "Pick a local or Omarchy color theme" }, - "blob.dynamic": { "icon": "", "label": "Dynamic theme", "action": "blob_theme --dynamic", "description": "Recolor from the current wallpaper" }, - "blob.glass": { "icon": "", "label": "Toggle glass", "action": "blob_glass toggle", "checked": "test -f $HOME/.local/state/omarchy/toggles/hypr/blob-glass.lua" } + "blob": { "icon": "󰖌", "label": "Blob", "before": "learn" }, + "blob.wallpaper": { "icon": "󰸉", "label": "Wallpaper", "action": "blob_wallpaper --menu", "description": "Pick a wallpaper from ~/wallpapers" }, + "blob.theme": { "icon": "󰢵", "label": "Theme", "action": "blob_theme --menu", "description": "Pick a local or Omarchy color theme" }, + "blob.dynamic": { "icon": "󰁨", "label": "Dynamic theme", "action": "blob_theme --dynamic", "description": "Recolor from the current wallpaper" }, + "blob.glass": { "icon": "󱡓", "label": "Toggle glass", "action": "blob_glass toggle", "checked": "test -f $HOME/.local/state/omarchy/toggles/hypr/blob-glass.lua" } } diff --git a/omarchy/plugins/blob.menu/MenuModel.js b/omarchy/plugins/blob.menu/MenuModel.js index c6dc7ed..e4387f0 100644 --- a/omarchy/plugins/blob.menu/MenuModel.js +++ b/omarchy/plugins/blob.menu/MenuModel.js @@ -23,6 +23,7 @@ function normalizeItem(id, raw) { return { id: id, parent: parent, + before: value.before || "", kind: kind, icon: value.icon || "", iconFont: value.iconFont || "", @@ -62,6 +63,26 @@ function parseMenuJsonc(raw) { return out } +// A row may name a sibling's id in `before:` to sit ahead of it. User rows are +// appended after every default row, so without this a new top-level entry can +// only land at the bottom of the root menu. +function applyBeforeHints(items, itemOrder) { + var order = itemOrder.slice() + + for (var i = 0; i < itemOrder.length; i++) { + var entry = items[itemOrder[i]] + if (!entry || !entry.before) continue + + var entryIndex = order.indexOf(entry.id) + if (entryIndex < 0 || order.indexOf(entry.before) < 0) continue + + order.splice(entryIndex, 1) + order.splice(order.indexOf(entry.before), 0, entry.id) + } + + return order +} + function mergeMenuSources(defaultItems, userItems) { var nextItems = ({}) var nextOrder = [] @@ -82,8 +103,10 @@ function mergeMenuSources(defaultItems, userItems) { } } + nextOrder = applyBeforeHints(nextItems, nextOrder) + if (!nextItems.root) { - nextItems.root = { id: "root", parent: "", kind: "menu", icon: "", iconFont: "", label: "Go", title: "", target: "", description: "", aliases: [], when: "", checked: "", action: "", provider: "" } + nextItems.root = { id: "root", parent: "", before: "", kind: "menu", icon: "", iconFont: "", label: "Go", title: "", target: "", description: "", aliases: [], when: "", checked: "", action: "", provider: "" } nextOrder.unshift("root") } for (var k3 = 0; k3 < nextOrder.length; k3++) nextItems[nextOrder[k3]].order = k3